-5

I perform one task to hear ........I am searching data like google search engine in performing that i can only select value using mouse how can I select that data using arrow key? My code is below.

<html>
<head>
<script type="text/javascript">
function showResult(str)
{
if (str.length==0)
  {
  document.getElementById("livesearch").innerHTML="";
  document.getElementById("livesearch").style.border="0px";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
    document.getElementById("livesearch").style.border="1px solid #A5ACB2";
    }
  }
xmlhttp.open("GET","livesearch.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

<form>
<input type="text" size="30" onkeyup="showResult(this.value)" />
<div id="livesearch"></div>
</form>

</body>
</html> 
Kishor
  • 1,513
  • 2
  • 15
  • 25
Parimal
  • 31
  • 1
  • 1
  • 4

1 Answers1

1

Your question is fairly vague, but you sound like you want to use the arrow keys from within Javascript. This has been asked before: Binding arrow keys in JS/jQuery.

jQuery would also make your AJAX requests a lot easier to write. For examples, see the documentation of jQuery.get().

It's difficult to tell you how to write the Javascript to select a specific item (like in Google), because that depends on what is returned by the AJAX request (xmlhttp.responseText).

Community
  • 1
  • 1
Sam Starling
  • 5,298
  • 3
  • 35
  • 52