jquery easyui三级联动

直接上代码:

//省市区三级联动
    var $province = $('#userAttrArea');
    var $city = $('#userAttrCity');
    var $County = $('#userAttrCounty');
    var provinceId = $province.combobox({
        onChange:function(newValue, oldValue){
            //刷新数据,重新读取省份下的城市,并清空当前输入的值
            if(newValue != ""){
                var city = $city.combobox({
                    disabled:false,
                    url:'query/area/' + newValue + '/json',
                    valueField:'id',
                    textField:'name',
                    onLoadSuccess:function(){ //第2选中
                        var combobox = $city.combobox('getData');
                        $city.combobox('setText',combobox[1].name).combobox('setValue',combobox[1].id);
                    },
                    onChange:function(newValue, oldValue){
                        if(newValue != ""){
                            //刷新数据,重新读取省份下的城市,并清空当前输入的值
                            $County.combobox({
                                disabled:false,
                                url:'query/area/' + newValue + '/json',
                                valueField:'id',
                                textField:'name',
                                onLoadSuccess:function(){ //第2选中
                                    var combobox = $County.combobox('getData');
                                    $County.combobox('setText',combobox[1].name).combobox('setValue',combobox[1].id);
                                }

                            });//.combobox('clear');

                        }
                    }
                });//.combobox('clear');
            }
        }
    });

相关推荐