I'm trying to create a form that when we select the value on the autocomplete field it will fill some other fields, autocomplete is working but I can't make it fill the second field, can someone point me the way, I think is something with my PHP file?
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
// Check connection
if (isset($_GET['term'])) {
$query = "SELECT * FROM registo_obra WHERE Contrato LIKE '{$_GET['term']}%' LIMIT 25";
$result = mysqli_query($db, $query);
if (mysqli_num_rows($result) > 0) {
while ($user = mysqli_fetch_array($result)) {
$res[] = $user['Contrato'];
$res[] = $user['cliente'];
$res[] = $user['descricao'];
array_push( $return_arr, $res );
}
} else {
$res = array();
}
//return json res
echo json_encode($res),"\n";;
}
Here is my jQuery
<script>
$(function() {
$("#Editbox1").autocomplete({
source: "data2.php",
select: function (event, ui) {
var item = ui.item;
if(item) {
$("#wb_Text1").html(item.cliente);
$("#wb_Text2").html(item.descricao);
}
}
});
});
</script>