Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8599693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:27:05+00:00 2026-06-12T01:27:05+00:00

I am building a dynamic small lenght converter that contains 3 input[text]s. Like so

  • 0

I am building a dynamic small lenght converter that contains 3 input[text]s. Like so

<input type='text' class='bx' id='cm'> Centimeter<br>
<input type='text' class='bx' id='m'> Meter<br>
<input type='text' class='bx' id='km'> Kilometer<br>

The effect is the following: if you click on “Meter” the value becomes ” and if you type a value the “Centimeter” and “Kilometer” value will be equal to a value(…).

Example

The jquery is like so:

$(function() {

var selected = ????;

// do i need something here to empty the input it is focused on?

$("#cm").val(selected * 545);
$("#km").val(selected * 545);
$("#m").val(selected * 453);

})

I want the var selected to be equal to the value of the text input it is focused on.

How can i do this?

The calculation in examples are informative.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:27:06+00:00Added an answer on June 12, 2026 at 1:27 am
    var selected = $(this).val();
    

    // // The code you have written will only work fro the first time your page loads. If you want it to work on every click of it you need to handle the focus event of the input..

     $('#cm , #km , #m').on('focus', function() {
            var selected = parseInt($(this).val() , 10) ; // Will convert to a Int
    
            $("#cm").val(selected * 545);
            $("#km").val(selected * 545);
            $("#m").val(selected * 453);
    
        });
    

    But I think a blur event makes more sense here instead of a focus event..

    FIDDLE

    Which will point to the value of the selected input

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a website that would serve dynamic content. All communication between server/browser
I am building a website that is basically a small Content Management System. (in
For a University assignment I'm building a class structure that includes, in part, several
t += '<td ><input type=text maxlength=5 size=5 id =text. + i + name=tx/></td>'; Iam
I am building a dynamic form in that the user can keep adding entries
I am building a dynamic form creator that allows users to add form elements
I am currently building a dynamic form that allows the user to add as
I am building a dynamic form system that will automatically assemble an HTML form
I am building a dynamic partial load asp.net page, I would like to use
I am building some dynamic controls and would like to convert the following XAML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.