The first letter you enter creates a pull-down menu of all items in a database that start with that letter...
views:
61answers:
2Hi,
Using Plugins/Autocomplete/autocomplete, it seems you can use "local" data, directly into the JS code, ie without having to do an Ajax request to the server :
autocomplete( url or data, [options] )
url or data
: String, Array
An URL pointing at a remote resource or local data as an array.
options (Optional)
: Options
A set of key/value pairs that configure the autocomplete. All options are optional.
So, you need a way to convert the data you have on the PHP side to some Javascript array.
If you are using PHP >= 5.2, you can use the json_encode
function to do that.
For instance, you can have this kind of PHP code :
$data = array(
'first',
'second',
'third',
);
$js_array = json_encode($data);
echo "var my_list = {$js_array};";
And the output you'll get looks like this :
var my_list = ["first","second","third"];
Which declares an initializes some Javascript array containing the results ;; up to you to put that kind of code where it belongs ;-)
Have fun !