Use ASP + jquery. autocomplete. js to implement the auto-Prompt function similar to Google

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.