// Jquery class library
<SCRIPT type = "text/JavaScript" src = "http://jquery.bassistance.de/autocomplete/lib/jquery.js"> </SCRIPT>
<SCRIPT type = 'text/JavaScript 'src = 'HTTP: // jquery.bassistance.de/autocomplete/jquery.autocomplete.js'> </SCRIPT>
// Css Style
<LINK rel = "stylesheet" type = "text/CSS" href = "http://jquery.bassistance.de/autocomplete/jquery.autocomplete.css"/>
// A text box is required for the page
Search: <input type = "text" name = "Q" id = "query_s" style = "width: 300px"/>
// JS script
<SCRIPT type = "text/JavaScript">
$ (). Ready (function (){
Function Format (Mail ){
Return mail. Name
}
$ ("# Query_s"). Focus (). AutoComplete ('search. ashx ,{
Multiple: false, // whether to allow append in the search box
// Multipleseparator: ',', // format of the suffix appended to the search box, for example, search value 1 and search value 2
Datatype: "JSON", // JSON type
Parse: function (data ){
Return $. Map (data, function (ROW ){
Return {
Data: Row,
Value: Row. Name,
Result: Row. Name
}
});
},
Formatitem: function (item ){
Return format (item );
}
}). Result (function (E, item ){
Window. Location. href = item. To; // jump after selection
// $ ("# Content"). append ("<p> selected" + format (item) + "</P>"); specifies the display information of a div.
}
);
});
</SCRIPT>
// Search. ashx
String STR = context. request ["Q"]; // receives the Q parameter, which automatically returns the value of the search box.
/********/
Return JSON data
/*********/
// JSON data. I search for "8"
[{Name: "888", to: "user_test.aspx? Taskid = taskexecid & year = 2012 "},{ name:" 892 ", to:" user_test.aspx? Taskid = taskexecid & year = 2012 "}]