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!

<input type="text"> with onchange event

Status
Not open for further replies.

thumpkidd9

Programmer
Mar 27, 2005
42
US
Hey guys,

I had originally posted this under the HTML forum but someone suggested I try here. I was just trying to make a simple script that populates my <div> tag for each letter I type in the search text field.

This is the line that calls the search is below where this.value = the input from keyboard, searchDiv is the ID of the <div> tag and fileS.php is the file that does the searching.

Code:
<input type="text size="10" name="search" onchange="grabData(this.value,'searchDiv','fileS.php')" />

The search works fine, the problem I am running into is that the onchange event doesn't happen until I hit enter on the search text field (with <textarea> if I lose focus of the textarea box by clicking off it, it will get my results as well).

I was curious if there was just no way to have the <input type=text> box update per keychange and not when hitting enter. I have tried the following to no avail (onkeyup, onkeydown, onkeypress).

Any help would be great.

Thanks !
 
onkeypress is the one you want. On change only fires when the object loses focus.


Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Enable Apps
 
Thanks that works. At first I didn't think it did because the letters ran a query on 5000 or so rows and it took some time to send that request through ajax. Thanks again !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top