i’ve used .load() with jquery to call a php file that will return search results back into a div below a search input bar, but in the div, using TAB or down arrow will not cycle through the results.
It’s apparent the key controls don’t know the new div of results exists.
What am i looking for exactly to fix this?
I’ve called my php file that returns results from mysql db with the following code
$("#searchinput").keydown(function(e) {
if(e.which == 8) {
SearchText = $("#searchinput").val().substring(0,$("#searchinput").val().length-1);
}
$("#searchresults").load("inc/ajax_search.php", { searchinput:SearchText });
$("#searchresults").slideDown();
As cruxst suggests, there are plugins for this kind of thing, but maybe you don’t want to use a plugin. Perhaps you are trying to figure it out for yourself.
Here is a piece of code that implements a very simple autocomplete. It’s not a plugin and it’s pretty basic but it has the basic features.
Your question suggests that the function that you may be interested in is
highlightResult.Below the script is the markup and style required.
Requirements
Return from your ajax call assumed to be something like