Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making Two Input Fields Match

Status
Not open for further replies.

stonicus

Programmer
May 14, 2007
1
US
I was wondering how to make two input fields match. I have fields for address and billing address. I want to be able to make a check box to say "use address as billing address", since most of the time the two will be the same. I'd like to have it so if the box is checked and someone edits the address fields, it updates the billing address fields as well in real time. I make the business address fields disabled, but you can still see the text in the fields.

Currently, I use an onKeyPress event in the address fields, and set the business address to the address.value + the new key, with a special catch for backspace. This works great, until someone starts usng the arrow keys to go back and edit the address fields by inserting text or using the delete key.

Is there a way to make the business address fields think that whatever key is pressed in the address fields is also pressed in them, or pass the 'onKeyPress' event to the business address field?

Thank you in advance.
 
Use the onkeyup event for your copy.

Code:
<input type="text" id="textField1" onkeyup="document.getElementById('textField2').value = document.getElementById('textField1').value" />

<input type="text" id="textField2" />

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top