i have this,
that bring back values from the database here is my php section
i would like, when i select a name from the auto suggest to be able to have the id be filled in a input text area...
uncle Google says this, but i am having a hard time implementing it.
Code:
$(function() {
$('#input').autocomplete('test.php', {json: true});
});
Code:
$result = mysqli_query($db,$query);
while( $row = mysqli_fetch_array($result) )
{
$aResults[] = array( "id"=>($row['s_id']) ,"value"=>($row['s_last']), "info"=>($row['s_first']) );
}
$return = array();
foreach ($aResults as $key => $res) {
$return[] =$res['value'] . ' , ' . $res['info'];
}
echo json_encode($return);
}
}
}
uncle Google says this, but i am having a hard time implementing it.
Code:
myCallback = function(li, $input) {
// I need to refer to the appropriate "myXxxInput" here
alert($input.attr('id'));
}
setup = function() {
setupInput($('#myFirstInput'));
setupInput($('#mySecondInput'));
}
function setupInput($input) {
$input.autocomplete('blah.php', {onItemSelect: function(li) {
myCallback(li, $input);} });
}