多个下拉框,按顺序选择

多个下拉框,按顺序选择,并且每个下拉框中内容相同

 var myArray = [];
        function funDllEvent() {
            $(".easelect").change(function () {
                //console.info(myArray);
                var vVal = $(this).attr("index");
                var vDdlIndex = parseInt(vVal) - 1;
                if ($(this).val() != "") {
                    //获取事件
                    if ($.inArray($(this).val(), myArray) >= 0) {
                        var msgModel = { MsgType: "warning", msg: "选择项(" + $(this).find("option:selected").text() + ")重复", result: false, msgTitle: "系统提示" };
                        BPM.ShowMsg(msgModel);
                        $(".easelect:eq(" + vVal + ")").val("").chosen("destroy").chosen();
                        //return false;
                    } else {
                        myArray[vDdlIndex] = $(this).val();
                        //return true; 
                    } 
                    $("#dropBudCol" + (parseInt(vVal) + 1)).prop('disabled', false).trigger("chosen:updated");
                }
                else { 
                    var vSel = myArray[vDdlIndex]; 
                    var vArrIndex = vDdlIndex; //要移除的数组索引 固定不变
                    var vArrLen = myArray.length;//数组长度
                    for (var i = vArrIndex; i < vArrLen; i++) {
                        myArray.splice(vArrIndex, 1); //删除元素
                    }
                    $(".easelect:gt(" + vDdlIndex + ")").val("").chosen("destroy").chosen();
                    $(".easelect:gt(" + vDdlIndex + ")").prop('disabled', true).trigger("chosen:updated");
                }
                console.info(myArray); //测试已通过
                console.info("-------------------------");
            });
            $(".easelect:gt(0)").prop('disabled', true).trigger("chosen:updated");
        }


原文地址:https://www.cnblogs.com/MartinLee/p/7622629.html