这是我的第一页。以下是自动填充功能:
<script>
$(function() {
$("#skills").autocomplete({
source: 'search.php',
minLength:1,
select: function(event,ui){ *//autocomplete*
var code = ui.item.id;
if(code != '') {
}
}
});
});
</script>
我的search.php页面
$query = $db->query("SELECT *
FROM patient
WHERE FirstName LIKE '%$searchTerm%'
OR MiddleName LIKE '%$searchTerm%'
OR LastName LIKE '%$searchTerm%'
OR PatientId LIKE '%$searchTerm%'");
while ($row = $query->fetch_assoc()) {
$data[] = $row['FirstName']." ".$row['MiddleName']." ".$row['LastName'];
$id = htmlentities(stripslashes($row['PatientId'])); *//i want to pass this value*
}
//return json data
echo json_encode($data);
我使用了jQuery自动完成功能。我想将$id
值传递回第1页。我怎么能通过呢?有人能帮助我吗?
答案 0 :(得分:0)
只需添加一个包含每个项目的标签和值的数组
$label = $row['FirstName']." ".$row['MiddleName']." ".$row['LastName'];
$value = htmlentities(stripslashes($row['PatientId']));
$data[] = array('label' => $label, 'value' => $value);