<div class= "searchwellist" > Quick query: <select id= "Searchselect" runat= "Server" ><option value= "1" selected= "Selected" > by inner tube code </option><option value= "2" > by tag Code </option></select></div>
<div class= "Searchwel" id= "Search_div" ><input "text" type= "id=" "fastsearchtxt" input the individual code or the inner tube code "value=". NameList " onfocus=" if (value== ' input individual encoding or inner tube encoding ') {value= '} ' onblur= ' if (value== ') {value= ' input individual encoding or inner tube encoding '} '/>< /div>
Here is the referenced JS file
$ (document). Ready (function () {$ ("#fastsearchTxt"). KeyUp (function () {//ajax Get database query data var = $ ("#fast
Searchtxt "). Val ();
var num = $ ("#searchSelect option:selected"). Val ();
$.ajax ({type: "POST", url: "ajaxsearch.aspx", Data: ' Data= ' +data+ ' &num= ' +num,
Success:function (Message) {$ (' #fastsearchTxt '). Bedropdownlist (message);
}
});
});
}); (function ($) {$.fn.bedropdownlist = function (data) {//default value var defaults = {data: [' not
Hing ']};
var options = {Data:data}; options = $.extend (defaults, options);
Make parameter override var bindevent = function (o) {var tmpid = "Tmpselector_" + $ (o). attr ("id");//Generate temporary ID
if ($ ("#" + tmpid). Length > 0) {$ ("#" + tmpid). Remove (); Return Quit, do not go on} var datas = Options.data.split (', '); //data source//This style is set to absolute var html = "<div id=" "+ tmpid +" ' style= ' border:1px solid grey;m Ax-height:150px;position:absolute;text-align:left; overflow:auto;background:white;width:153px; '
><ul class= ' ui-menu ' > '; Dynamically generate a div containing Li element for (Var item in datas) {html + + <li> "+ Datas[item] +" </li>
";
HTML = = "</ul></div>";
var left = $ (o). Offset (). Left;
var top = $ (o). Offset (). Top + $ (o). Height () + 4; The var finalize = function () {$ ("#" + tmpid + "Li"). Unbind (' click ');//Cancel Event binding $ ("#" + tmpid
). Remove ();
};
Sets the width, position, and so on of the div.
$ ("#" + tmpid). Width ($ (o). Width () + 100);
$ ("#" + tmpid). Offset ({top:top, left:left});
$ ("#" + tmpid). Remove ();
$ ("#search_div"). Append (HTML); $ ("#" + tmpid). MoUseleave (function () {finalize ();});
$ ("#" + tmpid+ "Li"). Click (function () {$ (O). Val ($ (this). text ());
Finalize ();
if (fn!= undefined) {fn ();//Call the function passed in.
}
});
};
This.each (function () {//Because the selectors of jquery may match multiple objects, you need each to operate on each matching element. if ($ (this). Is (": text") = = True) {//$ (this). KeyUp (function () {Bindev ENT ($ (this));
Set the content to do//});
}
});
}; }) (JQuery);