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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate fields from keypress event from another form field. 1

Status
Not open for further replies.

tcode

Programmer
Jan 8, 2004
15
0
0
US
I have a form that requests 2 separate addresses (addr1,addr2,city,state,and zip fields). As a user enters keyboard strokes into the street address field, I'd like it to also populate the street address field for the second street address area. The user should be allowed to modify the second. This will save them keystrokes when the address locations are the same. Is there a javascript class that will allow me to do this? Thanks!
 
You can try something like this. The user can modify the 2nd address and it won't affect the first. However, take note that if the user goes back to modify address1 after they have modified address2 then it will overwrite their changes to address2.
Code:
<html>
<body>
<form name=blahForm>
<input type=text name=text1 onkeyup='blahForm.text2.value = this.value'>Address1<br>
<input type=text name=text2>Address2
</form>
</body>
</html>

-kaht

banghead.gif
 
Ya know, I'd really be more likely to add a "Same as Above" button to my second Address set... click it and copy the whole shootin' match to the second set of fields. Then edit to your heart's content. Neither field set is specifically "tied" to the other, but when you want to copy the info, simply click the copy button.

As a user, I would be distracted or confused by the characters popping into two fields at once.

Plus, there's alot less script-activity when you don't have to check every keystroke.

Just my two cents.

[red]Note:[/red] [gray]The above comments are the opinionated ravings of Mr3Putt. As such, Mr3Putt accepts no responsibility for damages, real or contrived, resulting from acceptance of his opinions as fact.[/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top