kodlarım aşağıdadır.
index.php dosyası:
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
var url = "islem.php";
$("#search-box").keyup(function(){
$.ajax({
type: "POST",
url: url,
data:'keyword='+$(this).val(),
beforeSend: function(){
$("#search-box").css("background","#FFF url(LoaderIcon.gif) no-repeat 165px");
},
success: function(data){
$("#suggesstion-box").show();
$("#suggesstion-box").html(data);
$("#search-box").css("background","#FFF");
}
});
});
});
function selectCountry(val) {
$("#search-box").val(val);
$("#suggesstion-box").hide();
}
</script>
<div class="frmSearch">
<input type="text" id="search-box" placeholder="ara" />
<div id="suggesstion-box"></div>
</div>islem.php dosyası:<?php
if(!empty($_POST["keyword"])) {
$query =mysql_query("SELECT * FROM country WHERE name like '" . $_POST["keyword"] . "%' ORDER BY name LIMIT 0,6");
$result = mysql_num_rows($query);
if($result > 0) {
?>
<div style="padding-bottom:2px;padding-top:2px">
<button>TÜMÜ</button> <button>SEÇENEK 1</button> <button>SEÇENEK 2</button> <button>SEÇENEK 3</button>
</div>
<ul id="country-list">
<?php
while($country=mysql_fetch_array($query))
{
?>
<li onClick="selectCountry('<?php echo $country["name"]; ?>');"><?php echo $country["name"]; ?></li>
<?php } ?>
</ul>
<?php } } ?>