I have just started using jQuery autocomplete and for simple searches this works well. However, what I would like to do is send a hidden input with a value to search.php to refine my search.
For example, when autocomplete sends data to search.php it uses term and this is evaluated in search.php as $_GET['term']
. What I need to do is send a hidden input with a value and extract the value in search.php something like $_GET['hidden'];
Is this possible in autocomplete. Thanks
$(function () {
$(".search").autocomplete({
source: "search.php",
minLength: 2,
select: function (event, ui) {
var v = ui.item.value;
console.log(v);
return false;
}
});
});
You could pass a parameter as query string. If your input hidden as id equals to hidden(it's only an example), so:
$(function () {
var hidden = $('#hidden').val();
$(".search").autocomplete({
source: "search.php?parameter="+hidden,
minLength: 2,
select: function (event, ui) {
var v = ui.item.value;
console.log(v);
return false;
}
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.