I am using the official Jquery Autocomplete plugin. I have an ODBC database with a list of advertisers. I currently have an input box where the user types in part of the name and I am successfully returning a list of partial matches. The problem I'm having is I do not understand how to return both the name and the ID of the advertiser. I am assuming I will want to use a Jquery function to adjust the value of a hidden field to store the ID after retrieving it.
php file to return the advertiser name that needs to be modified to return the UsageNumber as well:
$sql = "SELECT DISTINCT tNAdvertisors.UserName, tNAdvertisors.UsageNumber
FROM tNAdvertisors
WHERE (((tNAdvertisors.UserName) Like '$term%'));";
$rs=odbc_exec($conn,$sql);
$a = array();
while (odbc_fetch_row($rs)) {
$a[] = htmlentities(odbc_result($rs,"UserName"));
}
echo json_encode($a);
current jquery code for the autocomplete that needs to be modified to include a function to handle the ID?
$("#single").autocomplete({
source: "ajaxSearchForAdvertiser.php",
minLength: 3
});
Thank you for your time and help.