Test.html Code
<! Doctype HTML public " -// W3C // dtd html 4.01 transitional // en " " Http://www.w3.org/TR/html4/loose.dtd " >
< Html >
< Meta HTTP - Equiv = " Content-Type " Content = " Text/html; charset = UTF-8 " />
< Head >
< LINK rel = " Stylesheet " Href = " Jquery.autocomplete.css " Type = " Text/CSS " />
< Script SRC = " Jquery-latest.js " > </ Script >
< Script Type = " Text/JavaScript " SRC = " Jquery. autocomplete. js " > </ Script >
< Script >
Function findvalue (LI ){
If (Li = Null )
Return Alert ( " No match! " );
If ( !! Li. Extra)
VaR svalue = Li. Extra [ 0 ];
Else
VaR svalue = Li. selectvalue;
}
Function selectitem (LI ){
Findvalue (LI );
}
Function formatitem (ROW ){
Return Row [ 0 ];
}
$ (Document). Ready (function (){
$ ( " # Example " ). AutoComplete ( " Test. asp " ,{
Delay: 10 ,
Minchars: 0 ,
Matchsubset: 0 ,
Matchcontains: 1 ,
Cachelength: 10 ,
Onitemselect: selectitem,
Onfindvalue: findvalue,
Formatitem: formatitem,
AutoFill: True
});
});
</ Script >
</ Head >
< Body >
< Input ID = " Example " Size = " 50 " />
</ Body >
</ Html >
Test. asp Code
<%
Response. contenttype = " Text/html "
Response. charset = " UTF-8 "
Set Conn = Server. Createobject ( " ADODB. Connection " )
Conn. connectionstring = " Provider = sqloledb; Data Source = 192.168.1.20; uid = sa; Pwd = 123456; initial catalog = turbocms_6008; "
Conn. Open
SQL _str = " Select ID, keyword from cms_content where keyword like '% " & Request. querystring ( " Q " ) & " %' "
Set RS = Server. Createobject ( " ADODB. recordset " )
Rs. Open SQL _str, Conn, 1 , 3
Do WhileNot Rs. EOF
Datas=Datas&RS ("Keyword")&Vbcrlf
Rs. movenext
Loop
Response. Write (datas)
%>
Download ASP + jquery. autocomplete. js from the source code