Hi All, Need some quick help. Please see my code below. When I start typing in the search box the Suggestions are shown below as a table but i need them like Google suggest(live search). Please help me on this. HTML FILE <html> <head> <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; 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("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <input type="text" id="txt1" size="30" onkeyup="showUser(this.value)" autocomplete="off" /> <div id="livesearch"></div> </form> <br /> <div id="txtHint"><b>Your group will be listed here</b></div> </body> </html> Code (markup): PHP FILE <?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'root', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("needsesearch", $con); $sql="SELECT title FROM `jos_sections` WHERE title like '%".$q."%' "; $result = mysql_query($sql); echo "<table border='1'> <tr> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['title'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Code (markup):
Hi, If you get the result correctly and you only have design issue then JUST remove the border =1 " and ADD "cellpadding=0 cellspacing=0" . May it will help you.
hi vetrivel, its not just a design issue. I need the results to get displayed just below the search box and when we move the down arrow key it should get selected.
hi roopajyothi, please see the screenshots below. For example when i type 'a', it finds all the results with 'a'. BUt i need it with the suggest box. The result Need it like this.
You can use some js library. like yui dojo mootools jquery etc...doing it yourself will make lots of issues. Generally browser compatibility issues... so better use some js lib. I used yui for this... but others are good too. Thanks...