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

problem with keystroke-events

Status
Not open for further replies.

theemperor

Programmer
May 22, 2001
28
AT
Hi all,

I'm trying to do the following: the user types a letter (or numeral or some special chars) into a input box. Depending on the value of the input box, all entries in an array starting with exatly that string ar beeing displayed in a table underneath the input box (it is going to be a combo box). My problem now is when I'm trying to catch the onkeypress-event (I use this one because it only fires on letters, numerals, some special chars, space, esc and enter) and get the value of the input box afterwards with the getAttribute('value')-function, the character I just typed in isn't in the value of the input box. This is because the onkeypress-event is just like the onkeydown-event, except that it doesn't fires on every key.

Has anybody got an idea of how I could solve or work around this problem???

Thanx for any help!

Regards,
Robert
 
In my experience with this problem, I've always used a setTimeout when trying to detect a key press.

As for your getAttribute() thing... In JavaScript, form elements have a .value property. Because .getAttribute doesn't work in older browsers, I suggest accessing the input's .value property. It's there for a reason.
Code:
- UNIMENT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top