基于JQUERY的多级联动代码_jquery_脚本之家

作者:官方彩票手机投注网站-服务器运维

jquery.select.more.js 复制代码 代码如下: { $.fn.doselectmore = function { var dfop ={ namekey: "name", pnamekey: "name", idkey: "id", selectname:"sel", method: "POST", datatype: "json", param:{}, pval:null, chckval:null, chckvalarry:null, pname:false, nname:false, vl:0, url: false, data: false }; $.extend; // alert; var me = $; if{ dfop.nname = (dfop.selectname+; } if&&dfop.vl>0){ dfop.pname = dfop.selectname+; } if{ if { var param = {}; $.ajax({ type: dfop.method, url: dfop.url, data: dfop.param, dataType: dfop.datatype, success: function{ dfop.data=data; selectmorebuilder; }, error:(function{ var errText = request.responseText; var ErrMessage = "页面出现"+request.status+"错误信息,n"; ErrMessage += "错误内容为:"+request.statusText+"n"+errText.substring(errText.indexOf+5,errText.indexOf; alert; } }else{ selectmorebuilder; } function selectmorebuilder { if(df.chckval!=null&&df.chckvalarry==null){ var pid=df.chckval; var k=1; df.chckvalarry = new Array(); df.chckvalarry.push{ k=0; $.each(df.data, function{ if(item[df.idkey]==pid&&item[df.pnamekey]!=df.pval){ pid=item[df.pnamekey]; df.chckvalarry.unshift; } } // alert; var select = $; select.attr({ name:df.selectname+dfop.vl, id:df.selectname+dfop.vl, nname:df.nname, pname:df.pname, vl:df.vl }); var sdiv = null; if { sdiv = $; thisme.after; sdiv.append(""); sdiv.append.t=df; }else{ thisme.removeselectmore(); sdiv = $("input[name="+df.selectname+"]").parent(); sdiv.append; } select.empty(); var counti = 0; $.each(df.data, function{ if(item[df.pnamekey]==df.pval){ select.append(""+item[df.namekey]+""); counti++; } }); if { select.remove(); } else { select.change{ var nselect = $.attr; if { nselect = $; sdiv.append; } nselect.doselectmore({ namekey: df.namekey, pnamekey: df.pnamekey, idkey: df.idkey, selectname: df.selectname, param: df.param, pval: $, vl: df.vl + 1, chckvalarry:sdiv.get.t.chckvalarry, data: df.data }); }); if{ if(df.chckvalarry.length>=df.vl) select.val(df.chckvalarry[df.vl]); } if(df.vl==1&&df.chckvalarry!=null&&df.chckvalarry[1]!=select.val{ var ddf = sdiv.get.t; ddf.chckvalarry=null; ddf.chckval=null; sdiv.get.t=ddf; } select.change(); $("input[type=hidden][name="+df.selectname+"]").val($("input[type=hidden][name="+df.selectname+"]").getselectmoreval; } } }; $.fn.getselectmoreval = function; if return; var sdiv = me.parent return; var df = sdiv.get.t; var nselect = $("#" + df.selectname+df.vl); var v = null; while{ v = nselect.val(); nselect = $("#" +nselect.attr; } return v; }; $.fn.setselectmoreval = function{ var me = $==0) return; var sdiv = me.parent return; var df = sdiv.get.t; df.chckval=idv; if{ var pid=df.chckval; var k=1; df.chckvalarry = new Array(); df.chckvalarry.push{ k=0; $.each(df.data, function{ if(item[df.idkey]==pid&&item[df.pnamekey]!=df.pval){ pid=item[df.pnamekey]; df.chckvalarry.unshift; } } sdiv.get.t=df; var nselect = $("#" + df.selectname+df.vl); nselect.val; nselect.change(); }; $.fn.removeselectmore = function.attr{ $.attr.removeselectmore; }; }); help.html 复制代码 代码如下: 

Insert title here

方法名:doselectmore
用途:实例化一个对象为多选框
例子:html

js:

 /** 一下※为必填项,★为二选一,?为不是必须 ※namekey: 数据类型显示名称, ※pnamekey: 数据上级主键名称, ※idkey: 数据主键名称, ※selectname: 选择框名称, ※pval:第一级别上级节点值, ?chckval:默认选择, ★url: false, ?param:url使用时传入参数, ★data: false **/ $("input[name=illegbasinfo]").doselectmore({ url:'../../../abc/dic/illbasinfo/loadall.do', pval:0, namekey: "illegbasinfo", pnamekey: "parillegbasid", idkey: "illegbasinfoid", selectname:"illegbasinfo" }); 

方法名:doselectmore
用途:得到选中对象值
例子:js:

 $.click{ alert($("input[name=illegbasinfo]").getselectmoreval; 

方法名:setselectmoreval
用途:为多选框设置值
例子:js:

 $.click{ $("input[name=illegbasinfo]").setselectmoreval; 

本文由彩票投注软件发布,转载请注明来源

关键词: