Auto Complete Search

<?php
$cars = array("facebook", "google");
?>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<form id="frm" method="post">
<input id="cartag" type="text" name="car">
</form>


<script>
$(function() {
var availableTags = <?php echo json_encode($cars); ?>;

$( "#cartag" ).autocomplete({
source: availableTags,
select: function (e, ui) {
if(ui.item.value=='facebook'){
window.location.href = "http://facebook.com";
} else if (ui.item.value=='google'){
window.location.href = "http://google.com";
}
}
});
});
</script>

Tinggalkan Komentar

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

×