problem with autocomplete script
I have a autocomplete script in PHP but problem with the code is I can't select suggested Values using my keyboard else script is running well with mouse but I wanna fix keyboard selection problem... Pasting a part of code with this....
$country = str_ireplace($str,"<b>".$str."&开发者_JS百科lt;/b>",($row['name']));
echo "<tr id=\"word".$row['id']."\" onmouseover=\"highlight(1,'".$row['id']."');\" onmouseout=\"highlight(0,'".$row['id']."');\" onClick=\"display('".$row['name']."');\" >\n<td>".$country."</td>\n</tr>\n";
even is selected onkeyup function.
For this kind of things, you should not try to re-invent the wheel1 -- instead, you should use some existing (used a lot, well tested, ...) solution !
For an example, take a look at jQuery's Autocomplete -- there's a demo at the bottom of the page ; you can see that the keyboard works, on this one.
1. and either fail, or spend hours or day debugging...
精彩评论