PDA

View Full Version : Jquery/ajax database lookup and form autocomplete



Jin
25-02-2011, 01:45 PM
I have been toying around with the best way of doing this:

I basically have a very extensive form:

The form breaks up into 2 parts,

Vehicles
&
Log

Each part relates to a separate table.

Now I have two fields in the vehicles section of my form "Reg Number:" & "Hire ID".

if one of these two fields has a string of X number of characters in it I want it to lookup this strings in the database and return values which can be assigned to a hidden field as well as auto-completing the rest of the vehicles form based upon what information is in the database otherwise the form can be completed as normal and the entry be submitted to the database.

any ideas or any links?

Dentafrice
27-02-2011, 03:11 PM
Like this?

http://docs.jquery.com/Plugins/autocomplete#Example

Are you wanting the help more specifically with the javascript side or the PHP side? On your AJAX call to the PHP, search the database and then return everything as an array with json_encode, very easy to combine with Javascript. Then populate the form.

Want to hide these adverts? Register an account for free!