Roy Tang

Programmer, engineer, scientist, critic, gamer, dreamer, and kid-at-heart.

Blog Notes Photos Links Archives About

If you want to use jquery ui autocomplete, your data must be “a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both”. This is from the documentation at http://jqueryui.com/demos/autocomplete/

Your server response does not follow the expected data type, you should modify suggest.php to post-process the data into label-value pairs.

As I understand it, you also want to perform a custom action when an item is selected from the autocomplete, so you should also add a handler for the ‘select’ event.

Comments

the source is work now but the select is not working. look at the question i add the code
in the SELECT property i can grab only the string i create in the source, string that i create from 3 variables, i want to know if i can SELECT each one of the variables for example i want to search for “HIL” and get HILTON LOS ANGELES USA suggest, when i select it it will show only “HILTON”, there is a way to solve it?
You can isolate the variable you want in the “value” property of the returned object, as described in the documentation. For your example, the object can be { “label” : “HILTON LOS ANGELES USA”, “value” : “HILTON” }