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

deleted a letter automatically in one field when i delete in another

Status
Not open for further replies.

rachelason

Programmer
Joined
Jun 28, 2004
Messages
114
Location
GB
HI! I am looking for some on user interface form
I have a page where there are two form, When i type in one form say the other form field get filled up automatically. I can do that easily, but when i try to delete a letter from the text box, it wouldn't delete it , any suggestion. this is the code.
<form name="f1">
<input type="text" name="name1" onkeypress="enteringvalue(f2.name2);">
</form>
<form name="f2">
<input type="text" name="name2"></form>

Script:
function enteringvalue(t2){
t2.value += String.fromCharCode(event.keyCode);
}
If i use onkeydown or onkeyup, it registers the event(delete event), but doesn't delete the letter and displays funny character for shift etc.
Has anyone done this kind of work before?
Thanks in advance
 
Here are my proposed changes:

FORMS:
Code:
<form name="f1">
<input type="text" name="name1" onkeyup="enteringvalue(this, document.f2.name2);">
</form>

<form name="f2">
<input type="text" name="name2">
</form>

FUNCTION:
Code:
function enteringvalue(t1, t2){
    t2.value = t1.value;
}

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
ohh, that was simple wasn't it? don't know why it didn't strike me, guess i am too tired of thinking. thanks for you help
 
hi again, the code works fine except that the second box always doesn't picks up last character. What i mean is if i type 'hello there' , the second form displays only 'hello ther', until i press a spacebar or do anything else int he same text box. am i missing out something?If i go to the next form variable obviously the textbox is left where it is. Any suggestion.
 
anyone had this problem before
no takers......
 
Did you use onkeyup like I suggested?

*cLFlaVA
----------------------------
"Holy crip he's a crapple!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top