需要引入
select2.full.min.js zh-CN.js select2.css
var select0 = $(".select0").children("select");
var select1 = $(".select1").children("select");
var select2 = $(".select2").children("select");
var select3 = $(".select3").children("select");
var select4 = $(".select4").children("select");
//给第一个下拉框的SelectChanged事件
select0.change(function (){
//取得当前下拉框的值
var select0Value = $(".select0").children("select").val();
//当第一个下拉框内容改变的时候,第三个下拉框要隐藏起来
select1.parent().hide();
select2.parent().hide();
select3.parent().hide();
select4.parent().hide();
if(select0Value !="")
{
var options = {
url: ctx + "xxx/xxx", // 数据接口url
pageSize: 20, // 每次加载的数据条数
value: "userId", // 下拉框value字段名称
name: "userName", // 下拉框显示字段名称
selected: [], // 默认选中项,格式:[{id:1,text:"选项1"},{id:2,text:"选项2"}]
param0: select0Value
};
ajaxSelect2("myselect1",options);
}
});
select1.change(function (){
var select0Value = $(".select0").children("select").val();
var select1Value = $(".select1").children("select").val();
select2.parent().hide();
select3.parent().hide();
select4.parent().hide();
if(select1Value !="" && select1Value!=null)
{
var options = {
url: ctx + "xxx