I need help and tips on how to implement this feature.
I have a search box. A correct search query could be: Cars in Paris. {category} in {location}.
- When the user starts to type the first char a search hint appears for the categories.
- The user selects “Car parts” from the hint options.
- “[space-key]in[space-key]” are added to the searchbox automatically after the selection of an option.
- A new search hint appears for the locations. User chooses Paris.
- Do the search after selection the location.
Any tips on how to implement this?
Here’s what I’d suggest:
Use jquery UI for auto suggest (very easy to implement, easy to customize to work for your specific situation) http://jqueryui.com/demos/autocomplete/. What I’d suggest is to have jQuery check whether the user is typing in a category or location (by seeing if the input is empty) and based on that, run a different autocomplete call.
jQuery UI has an event called ‘select’. Use that to add the chosen item + in into the text field.
Now, when the user types in something else, have jQuery recognize that it’s time for a location, and call jQuery UI autocompletion to suggest locations.