Jquery Autocomplete Two Fields Based On One Field Using Php And Mysql
I have a table in MySQL database with following columns: name, address, occupation, phone_number and serial_number. In my html form, among other fields, I have text fields for inpu
Solution 1:
What you need to do is, when the autocomplete of the serial number is finished, run an ajax-call to retrieve the name and phone number based on the serial number and then populate those fields, something like this:
$('input[name=serial_number]').autocomplete({
onComplete: function (val) {
$.getJSON('/url-to-fetch-name-and-phone.php?serial_number=' + val, function (data) {
$('input[name=name]').val(data.name);
$('input[name=tel]').val(data.tel);
});
}
});
Obviously you'll need to change some function and variable names depending on your setup.
Post a Comment for "Jquery Autocomplete Two Fields Based On One Field Using Php And Mysql"