Hi All, I am new to this place. I need help from anyone for implementing ajax in my project. I need to load some data as a list in Onchange/ Keyup event of <input type="text" name="txtsearch" value=""/>. Please see the attached file for more details... Please give me solution for this problem. Thanks in Advance. Regards, spm.
Well if you are doing .NET, then you can use the ASP.NET AJAX library, specifically the autocompletion control. See the asp.net/ajax site for samples (I can't post live links yet)
you can do it using asp. search autocomplete scripts on the web. most of them are in php. just, apply to asp script for server side, it is not hard.
I have impletemented the same for some of my application using classic ASP Refernce code Code for file where list will be displayed <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <html> <head> <script src="clienthint.js"></script> </head> <body> <form> Enter Word: <input type="text" id="txt1" onkeyup="showHint(this.value)"> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> Javascript code var xmlHttp function showHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="gethint.asp"; url=url+"?q="+str; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } ASP Code where you will fetch the list <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% response.expires=-1 Dim rsWords Dim rsWords_numRows Dim q Dim hint q=ucase(request.querystring("q")) hint="" Set rsWords = Server.CreateObject("ADODB.Recordset") rsWords.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db_hint_words.mdb") rsWords.Source = "SELECT * FROM TBL_WORDS WHERE (word LIKE'" + q + "%') ORDER BY WORD" rsWords.CursorType = 2 rsWords.CursorLocation = 2 rsWords.LockType = 3 rsWords.Open() rsWords_numRows = 0 If Not rsWords.EOF Then Do While Not rsWords.EOF If trim(hint) = "" Then hint = rsWords("word") Else hint = hint & " , " & rsWords("word") End If rsWords.MoveNext() Loop End If if trim(hint)="" then response.write("no suggestion") else response.write(hint) end if rsWords.Close() Set rsWords = Nothing %>