By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

Updating one textbox based on values in another, and using delete key

P: n/a
Hi All,
I have a page with three textboxes. Call them txt1, txt2, and txt3.
Using javascript I need to populate txt3 with whatever has been typed
into txt1 and txt2 as the information is being entered. No problem
there, but I want to update txt3 whenever the user uses the delete or
backspace key in either txt1 or txt2. I capture the delete or
backspace keystrokes, but when I try to update txt3 it is always a
step behind. That is at the time of the keystrokes the value of txt1
or txt2 has no yet been updated.
Does anyone have any suggestions for how to accomplish this?
TIA,
Sven
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Thermidor wrote:
Hi All,
I have a page with three textboxes. Call them txt1, txt2, and txt3.
Using javascript I need to populate txt3 with whatever has been typed
into txt1 and txt2 as the information is being entered. No problem
there, but I want to update txt3 whenever the user uses the delete or
backspace key in either txt1 or txt2. I capture the delete or
backspace keystrokes, but when I try to update txt3 it is always a
step behind. That is at the time of the keystrokes the value of txt1
or txt2 has no yet been updated.
Does anyone have any suggestions for how to accomplish this?
TIA,
Sven


Look at http://www.mozilla.org/docs/dom/domr...ef.html#998961

and
http://msdn.microsoft.com/library/de...nce/events.asp

and check the onkeypress event. You can access every keystroke.

Jul 20 '05 #2

P: n/a
@SM


Thermidor a ecrit :

Hi All,
I have a page with three textboxes. Call them txt1, txt2, and txt3.
Using javascript I need to populate txt3 with whatever has been typed
into txt1 and txt2 as the information is being entered. No problem
there, but I want to update txt3 whenever the user uses the delete or
backspace key in either txt1 or txt2. I capture the delete or
backspace keystrokes,


Why to use keys values (that are not same ie on PC & Mac)
when JS has KeyUp & KeyDown ?

<input type=text name=text1
onkeyup="text3.value=this.value+text2.value;">
<input type=text name=text2
onKeyUp="text3.value=text1.value+this.value;">
<input type=text name=text3
onKeyDown="truc=this.value;" onKeyUp="this.value=truc;">
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.