The autocomplete plugin ( http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/ ) is your best choice, especially if you are in the AJAXy application, as it goes to your server and gets a list of features in real time .
Usage example:
$("#sometextbox").autocomplete("search.php", { width: 260, selectFirst: false });
And then search.php may return:
Great Bittern|Botaurus stellaris Little Bittern|Ixobrychus minutus American Bittern|Botaurus lentiginosus
You can also dynamically generate output, because the plugin passes the text entered in querystring to the q parameter.
In response to running autocomplete without entering anything, the plugin does not support this, but it is quite simple to implement it in a hacker way:
The plugin intercepts an event of keyboard lock (or key press), for example (line 92 of non-minified code):
$input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete",...)
Therefore, you can make autostart work by doing something like:
$("#autocompletedInput").click(function() { $(this).trigger(($.browser.opera ? "keypress" : "keydown") + ".autocomplete"); }
Codes should trigger an event. You may need to pass a random key symbol to the trigger, so he wonders what is going on.
Kazar source share