Copy what user types in a text filed in to a hidden field

sahanz
sahanz used Ask the Experts™
on
In my page I have a text field <input type="text" name="txt" /> So what I want is, I want to add what user types in this filed in to a hidden field realtime, Would be gr8 if can be done using jquery
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Expert
Top Expert 2009
Commented:
no need for jQuery

<form>
<input type="hidden" name="htext" value="" />
<input type="text" name="txt" onKeyUp="this.form.htext.value=this.value" />
</form>

Author

Commented:
actually hidden value is in a different form
Michel PlungjanIT Expert
Top Expert 2009

Commented:
jQuery - something like :
<form>
<input type="hidden" name="htext" id="htext" value="" />
</form>
<form>
<input  type="text" name="txt" id="txt"/>
</form>
$("#txt").bind("keyup", function() {
  $("#htxt").val($(this).val())
});


Michel PlungjanIT Expert
Top Expert 2009

Commented:
Other form, no jQuery:



<form>
<input type="hidden" name="htext" value=""  />
</form>

<form>
<input type="text" name="txt" onKeyUp="document.forms[0].htext.value=this.value"  />
</form>

[0] denotes the FIRST (0th) form

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial