functionIniteselect (Options) {$ ("body"). Initeselect (Options)} (function($) {$.fn. Initeselect =function(options) {varoption = $.extend ({}, {ids: [], Swtype: [], CallBack: [], GUID: "", BaseUrl: "/ashx/dropdowncontrol.ashx", Split: ";", OB J: {}, Isgetfirstdrop:true}, Options);if(Option.ids.length = = 0) {return}Else{if(Option.isgetfirstdrop) {varc =NULL;if(Option.callBack.length > 0) {c = option.callback[0]} Getselectdata (option.ids[0], option. BASEURL, $.extend (Option.obj, {swtype:option.swtype[0], guid:option.guid}), c)} for(vari = 0; i < option.ids.length-1; i++) {bindchange (i, option)}if(!option.isgetfirstdrop && option.ids.length > 1) {$ ("#" + option.ids[0]). Change ()}} };functionBindchange (i, option) {$ ("#" + option.ids[i]). Change (function() {varValue = $ ("#" + Option.ids[i]). Val (); for(varK = i + 1; K < Option.ids.length; k++) {varids = Option.ids[k].split (option.split); for(varm = 0; M < ids.length; m++) {$ ("#" + ids[m] + "> option[value!= '-1 ']"). Remove ()}}varup = i + 1;if(Value = = "-1") {return}varc =NULL;if(Option.callBack.length >= up) {c = Option.callback[up]} GetSelectData2 (option.ids[up], option. BASEURL, Option.swtype[up], value, Option.split, C, Option.obj)}functionGetSelectData2 (IDs, URL, swtypes, V, split, C, obj) {varTeids = Ids.split (split);varTeswtypes = Swtypes.split (split); for(vari = 0; i < teswtypes.length; i++) {if(Teswtypes[i]! = "") {Getselectdata (teids[i], url, $.extend (obj, {swtype:teswtypes[i], guid:v}), c)}} }functionGetselectdata (ID, url, obj, c) {jquerypost (URL, obj,function(Result) {result = eval ("(" + result + ")");varIdobj = $ ("#" + ID); $ ("#" + ID + "> option[value!= '-1 ']"). Remove (); for(vari = 0; i < result.length; i++) {idobj.append ("<option value=" + result[i]. Value + "' >" + result[i]. Text + "</option>")}if(c! =NULL) {Window.settimeout (function() {C ()}, +)}})}) (JQuery);
How to use: Initeselect ({ids: [' Agentid ', ' orgId ', ' schoolid ', ' Departid/classid '], swtype: [' getallagent ', ' getorgdrop ', ' Getschooldrop ', ' Getschooldepart/getschoolclass ']});
The address or query cascade effect is very good, you can specify the parameters and the initial parameters. You can also specify a server-side URL.
Dropdown box Multi-level linkage auxiliary JS, optimize your drop-down box