当选择第一个下拉列表中的相同值时,禁用第二个下拉列表的相关值

时间:2016-10-13 07:46:22

标签: javascript jquery html jquery-mobile

当选择第一个下拉列表中的相同值时,禁用第二个下拉列表的perticualar值。这是 jsfiddle!是给定的链接 我必须在下面执行特定的操作是我的代码,它是调用数据的代码..

 Here is My Html

<select name="select-choice-1" class="filter-menu" id="dropDownFromCity">
                            <option value="">- -Select From City- -</option>
                        </select>
                      
                       
                        <select name="select-choice-1" class="filter-menu" id="dropDownToCity"   >
                            <option value="">- -Select To City- -</option>
                        </select>
                     
                       
                        <select name="select-choice-1" class="filter-menu" id="dropDownViaCity"  multiple="multiple" data-native-menu="false" data-placeholder="false" >
                             <option value="">- -Select Via Via- -</option>
                        </select>

这是我的jquery调用下拉数据

        function selectRadioButton() {
            var airPortId = $('input[name=airPortName]:checked').val();
            var loadingbar = $("#loadingBar");
            loadingbar.empty().append(window.loadingAnimation);
    
            setTimeout(function () {
                var Surl = "http://PassengerService.asmx/LoadDropDownlist";
                var dataString = "{'i':'" + airPortId + "'}";
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: Surl,
                    corssDomain: true,
                    data: dataString,
                    dataType: "json",
                    success: function (data) {
                        var jdata = $.parseJSON(data.d);
                        $("#dropDownFromCity").html("");
                        $("#dropDownToCity").html("");
                        $("#dropDownViaCity").html("");
                        //$("#dropdownViaCitySecond").html("");
                        $("#loadingBar").html("");
                        
                        $("#dropDownFromCity").append($("<option></option>").val("").html("- -Select From City- -"));
                        $("#dropDownToCity").append($("<option></option>").val("").html("- -Select To City- -"));
                        $("#dropDownViaCity").append($("<option></option>").val("").html("- -Select Via City- -"));
                        //$("#dropdownViaCitySecond").append($("<option></option>").val("").html("- -Select Via City- -"));
                        $.each(jdata, function (key, value) {
    
                            $("#dropDownFromCity").append($("<option></option>").val(value.AirportDetailsId).html(value.LocationDetail));
                            $("#dropDownToCity").append($("<option></option>").val(value.AirportDetailsId).html(value.LocationDetail));
                            $("#dropDownViaCity").append($("<option></option>").val(value.AirportDetailsId).html(value.LocationDetail));
                             
                            //$("#dropdownViaCitySecond").append($("<option></option>").val(value.AirportDetailsId).html(value.LocationDetail))
                        });
                        $("#dropDownViaCity").selectmenu().selectmenu('refresh');
                        
                        $("#dropDownFromCity-button").find('span').html("- -Select From City- -");
                        $("#dropDownToCity-button").find('span').html("- -Select To City- -");
                        $("#dropDownViaCity-button").find('span').html("- -Select Via City- -");
                        //$("#dropdownViaCitySecond-button").find('span').html("- -Select Via City- -");
                    }
                });
            }, 2000);
    
        }

以下是我对下拉类

的验证

 $('.filter-menu').on('change', function () {
            $('.filter-menu').find('option').prop('disabled', false);
    
            $('.filter-menu').each(function () {
                $('.filter-menu').not(this).find('option[value="' + this.value + '"]').prop('disabled', true);
            });
    
            // rebuild select menus
            $('select').selectmenu('refresh', true);
        });

0 个答案:

没有答案