Trying To Implement Live Search In A Input Box
i'm trying to implement live search in a textbox, the list of options coming from the server, if the item is not available it should add dynamically, like if i type 'gre' and selec
Solution 1:
This code will give you some idea.
HTML:
<input type="text"id="searchPro" />
Your all the dynamic result will be show inside the div
<div id="searchLog"></div>
JQuery:
$("#searchPro").autocomplete({
source: function(request,response) {
$.ajax({
url: "php.func.php",
type: "POST",
data: { term: request.term },
success: function (searchData) {
$('#searchLog').html(searchData);
}
})
}
});
PHP: php.func.php
$find = "SELECT *
FROM tbl_products
WHERE (`product_name` LIKE '%".$_REQUEST['term']."%')";
$resset = $conn->query($find);
while ($res = mysqli_fetch_object($resset)) {
$findRes[] = $res;
}
if (!empty($findRes)) {
foreach ($findResas$ResultSet) {
echo"<tr><td>".$ResultSet->product_name."</td>";
}
}else{
echo"<p>No Result Found for keyword <b>".$_REQUEST['term']."</b>..<p><hr/>";
}
Here is the link: [JQuery Autocomplete][1]
This is for your basic reference code i have use in my project. you can modify as per your need. Hope this will help you. For more https://jqueryui.com/autocomplete/
Post a Comment for "Trying To Implement Live Search In A Input Box"