Hi, recently my clients have asked me to change all the text input types to the auto complete suggestion boxes(Thanks to google's Auto Complete...)
I am good at server side programming but dont know how to make this work. If any one can suggest me some good script or tutorial , it will be really helpful.
auto complete is pretty easy actually, I believe <input type="text"/> has an event called onKeyUp, so you can get the text in the textbox every time they type...
so if they were typing 'Nike'
when they type the 'N' query your shoes table for 'Like "N%" '.
results for example:
and then when they type 'Ni' query your shoes table for ' Like "Ni%" '.
To do this you'll probably need to use ajax, because refreshing the page would look silly.
You down with OOP? Yeah you know me!
Joined: Jan 13, 2010
Thanks for the response. Can you give me any Hint how can i handle that in Ajax. I mean how can i send the string which i capture on keyup and prepare an Ajax request for the same.
Joined: Jan 24, 2006
the code above, just put into a file and save as AJAXLib.js
In the <head></head> of your html file just put:
now in a function that you call on onKeyUp, we'll call it autoComplete(this.value).
So the tag would look like <input type="Text" onclick="autoComplete(this.value)" />
The reason you have to make a callBackFunction is because when you make an ajax request, the response doesn't happen right away so you have to make a callbackfunction to handle the event when the response is ready to be dealt with.