tags:

views:

23

answers:

1

I have:

<form>
<input id="A" name="B">
<input id="C" name="D">
</form>

And I need to set the second input equal to the first whenever the first input is changed. Something like:

$(function() {
   $('input#A').change(function() {
   $('input#C').val(this.text);
   });
});
+2  A: 

This should do the trick:

$(function() {
   var myInput = $('#A');
   myInput.change(function() {
       $('#C').val(myInput.val());
   });
});
Agos
Thanks Agos!!!!
cf_PhillipSenn
You're welcome. Remember that often, in jQuery, the difference from a “getter” to a “setter” is just one parameter. myObj.val() vs. myObj.val(putThis), myObj.html() vs. myObj.html("<p>hi</p>"), myObj.attr('cellspacing') vs. myObj.attr('cellspacing', '5') et cetera.
Agos