nag research ko ug nice nga autocomplete.and nakit an ni nako ai
jQuery UI - Autocomplete Demos & Documentation
na achieve na nako ako gusto. pero di mu gana sa IE T^T
mao ni ang code ai.
js/jq
Code:
$().ready(function() {
$("#loc").autocomplete("database.php", {
width: 260,
selectFirst: false
});
});
HTML
Code:
<label>Location</label>
<input type="text" id="loc" />
<h3>Result:</h3> <ol id="result" style="border:1px solid red;"></ol>
PHP
Code:
$term = strtoupper($_GET["q"]);
$query = mysql_query("SELECT * from entityspecs where entitycode like '%$term%' ") or die(mysql_error());
$res = array();
while($row = mysql_fetch_assoc($query)){
$enty = $row['entitycode'];
$res[$enty] = $enty;
}
foreach ($res as $key=>$value) {
if (strpos(strtoupper($key), $term) !== false) {
echo "$key|$value\n";
}
}