I have the following code that I want to use to search a database as a user is typing into a textbox. The code below works fine but it seems a little inefficient, as if a user i
What I would do is each key press use a setTimeout function with the desired delay. So that function will fire after that timeout. Each key press then delete the timer and set a new one, with clearTimeout();
See here for some examples, scrolling past all the adverts.
http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/