Results 1 to 2 of 2
Thread: Predictive Text
Oct 27, 2009, 10:43 #1
I want to use predictive text on my website for a list of dropdown options. For example, if i have alist of States, town city etc. I want the text box to predict what the user will type.
See this example:-
Try typing something in the employer box..
First of all, is this free to use? if not i need to talk to my client. If it is, how can i use it?
Oct 27, 2009, 11:54 #2
- Join Date
- Jul 2008
- 0 Post(s)
- 0 Thread(s)
But, the gist of it is that you either use keyup or simply poll the text field for changes. When it changes, you fire off an ajax request to a serverside script that does something like
select something from sometable where something like 'goog%' limit 10
The above just does a simple substring search on the left of the string. This won't give you much as far as "predicting" what they will type, but it will return a list of possibilities. If you want to get into trying to provide the most likely 10 predictions, it can get pretty complicated. But, for making state/city suggestions, the simple left substring search should work pretty good because city/state names tend to be fairly unique, or at least enough to the point where offering up 5-10 suggestions will be likely to have a match in it.