Ryflex Posted June 3, 2011 Share Posted June 3, 2011 Hi all, I have a live search which gives as return value the name your looking for minus the letters you already typed in. Is it possible to get the return value in the textfield behind what you already typed. Underneath is my current code. <html> <head> <script type="text/javascript"> function showHint(str) { var xmlhttp; if (str.length==0) { 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","ajax_test.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <h3>Start typing a name in the input field below:</h3> <form action=""> First name: <input type="text" id="txt1" onkeyup="showHint(this.value)"/> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> Quote Link to comment Share on other sites More sharing options...
Ryflex Posted June 4, 2011 Author Share Posted June 4, 2011 Can anyone please help me out here Quote Link to comment Share on other sites More sharing options...
1981tarun Posted July 16, 2011 Share Posted July 16, 2011 Read this topic http://www.w3schools.com/php/php_ajax_livesearch.asp and http://www.reynoldsftw.com/2009/03/live-mysql-database-search-with-jquery/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.