I am using the jquery autocomplete with php/mysql . I want to retrieve 3 values from the database on autocomplete.
$("#shipper_name").autocomplete({
source: base_url + 'rainbowsoft/config/functions.php?shipper=shipper',
focus: function(event, ui) {
$("#shipper_name").val(ui.item.label);
return false;
},
select: function(event, ui) {
$("#shipper_name").val(ui.item.label);
$("#shipper_details").val(ui.item.value);
$("#client_id_shipper").val(ui.item.id);
return false;
}
});
Field with id - client_id_shipper is a hidden field which needs to store an id that is retrieved. My php/mysql returns:
$data[] = array(
'id'=>$row['id'],
'label' => $row['client_name'],
'value'=>$row['client_details'],
);
echo json_encode($data);
label and value are being displayed properly.SOme issue with the id.