当前位置: 代码迷 >> Web前端 >> jquery二级联动上拉框
  详细解决方案

jquery二级联动上拉框

热度:92   发布时间:2012-11-04 10:42:42.0
jquery二级联动下拉框
function doAjaxQuerySubBizType(val){
  var subBizType = $("#subBizType");
jQuery.ajax({
type:"post",
url:"subBizType.json",
data:{action:'query',bizType:val},
dataType:"json",
success:function(data){
createSubBizType(data.subBizType);
},
error:function(XMLHttpRequest, textStatus, errorThrown){

}
});
}

function createSubBizType(data){
var subBizType = document.getElementById('subBizType');
subBizType.options.length = 0;
subBizType.add(new Option('--请选择子业务类型--',''));
if(data!=null){
    jQuery.each(data, function(i, val){
      subBizType.add(new Option(val.desc,val.code));
    });
}
}

这个例子很简单,具体使用,不多说了,例如给下拉框的onchange时间绑定就行了,传入的参数的当前对象,写this问题不大
  相关解决方案