I hope that someone can point me in the right direction, then I should be able to figure this out and get it working...
Basically, I have a database of locations such as:
ID City/Town County
1 Newbury Berkshire
2 Preston Merseyside
Now my website has a form that the user fills in to indicate their address, within a section I have two input fields 'city' and 'county'. Here I would like three things to happen.
1) When the user begins to enter their city it auto completes based on results from the database (this would include their city and county, the county is just for identification so when selected would just input the city).
2) Once the user selects their city it auto completes the county field from the database.
3) With all this done I would like the ID from the city and county result to be entered into a hidden input element.
I have been looking all over the internet and found plenty of auto complete scripts: http://ajaxdump.com/2010/08/11/10-cool-auto-complete-scripts-using-ajaxjquerymootoolsprototype/ http://www.jqueryrain.com/2012/03/35-best-ajax-jquery-autocomplete-tutorial-plugin-with-examples/
and I have found various posts on form filling such as: Jquery autocomplete and PHP: populating input field with data from mySQL database based on selected option in autocomplete field
but I just can't seem to get them to work together. I am trying to stick with PHP, MYSQL and JavaScript. I am happy to use AJAX if needed, anything else is going beyond my knowledge of programming.
I maybe going about this all wrong, but any feedback or information that can point me in the right direction will be very gratefully received.
Many thanks
I actually found exactly the script I needed to do the job.
Go figure, spent a few days trying to figure it out, then within an our of uploading this post I found it!
For anyone else looking for the same thing its right here http://af-design.com/blog/2010/05/12/using-jquery-uis-autocomplete-to-populate-a-form/
enjoy!
This is fairly easy with jQuery. Just have your input detect $("input").keyup(function(){}); Then send a $getJson() request to a PHP script that queries your database. Then have PHP return a JSON string with the id,city and county. Load the JSON objects where you want.
I think yahoo provides best option for it YUI ;)
Previous answer : Follow this link ! it will sure help you .. Implementing Autosuggest With AJAX Into Your Site
Above link's name server are failing so sorry for that ! Try if website admin sort out it !