0

I have 3 HTML inputs. When modifying the text in input 1, input 2 should update with the text that was previously in input 1. Input 3 should similarly update with the text that was previously in input 2.

diagram

2
  • 1
    Please try to improve your English. It is not clear what you want. Commented Oct 19, 2012 at 11:32
  • I think it would be better if you take some courses in English language before learning Web programming language. Commented Oct 19, 2012 at 11:33

2 Answers 2

2

You can do it this way.

Live Demo

<input type="text" id="txt1" class="someclass" />
<input type="text" id="txt1" class="someclass" />
<input type="text" id="txt1" class="someclass" />​

$('.someclass').change(function(){
   $(this).next('.someclass').val($(this).val()); 
   $(this).next('.someclass').change();
});​

Binding keyup event will change as soon as you type something

Live Demo

Sign up to request clarification or add additional context in comments.

Comments

1

Use the jQuery val() method to set the input values as desired.

<!doctype html>
<html>
 <head>
 <script type="text/javascript" src="jquery.min.js"></script>
 <script type="text/javascript">
    $(document).ready(function(){
        $("#input1").keyup(function() {
            $('#input2').val($('#input1').val());
            $('#input3').val($('#input2').val());
        });
    });
 </script>
 </head>
 <body>
    <input type="text" id="input1" />
    <input type="text" id="input2" />
    <input type="text" id="input3" />
 </body>
</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.