基于其他多选下拉列表的多选下拉列表

multiselect dropdown based on other multiselect dropdown

我正在尝试 show/hide 多选下拉列表中的元素,基于另一个多选下拉列表中的选择。无论如何,当我使用 multiselect plugin 我无法 show/hide 这些元素。我的代码如下所示:

@Html.DropDownList("CompanyDropDown", new MultiSelectList(ViewBag.CompanyList,
         "COD_COMPANY", "DESCRIPTION", null), new
                {
                    multiple = "multiple",
                    @class = "multiselect",
                    onchange = "CompanyDropDownOnChange()"
                })


@Html.DropDownList("FlowDropDown", new MultiSelectList(ViewBag.ActiveFlow,
         "ID_FLOW", "DESCRIPTION", null), new
                {
                    multiple = "multiple",
                    @class = "multiselect",
                })

javascript 部分在这里:

jQuery(function ($) {
    $("select").multiselect();
});   
function CompanyDropDownOnChange() {
    $("#FlowDropDown option[value=11]").css('display', 'none');
}

The sample should just hide the flow with id=11 in the second dropdown, when a company in the first dropdown is selected.

我对像您这样的场景进行了一些测试,发现您更改了错误的元素。

function CompanyDropDownOnChange() {
 $("input[name=multiselect_FlowDropDown][value=11]").closest('li').css('display', 'none');
}

请参阅 this plunker 了解更多详情。