jQuery UI Autocomplete Widget with PHP and MySQL

The jQuery UI folks have released an autocomplete widget  that is pretty slick. This example uses the json_encode function in PHP 5. If you have an earlier version of PHP, you will have to roll your own JSON string.

This example will use US states and territories to populate the autocomplete. It will also demonstrate how to fill other fields with data returned from the database. This data can be used to fill a visible text box or a hidden form field. It also demonstrates the basic autocomplete functionality which may be fine for some applications.

Of course, you will need the jQuery core file, the jQuery UI core file, and the jQuery UI style sheet of choice. The style sheet comes from the themes available in the jQuery UI website and can be downloaded with the core file:

Demo : http://www.jensbits.com/demos/autocomplete/
Download : http://www.jensbits.com/media/code/autocomplete_PHP_jensbits.zip

No comments:

Post a Comment