基于其他多选下拉列表的多选下拉列表 [英] multiselect dropdown based on other multiselect dropdown
问题描述
我正在尝试根据另一个多选下拉列表中的选择来显示/隐藏多选下拉列表中的元素.无论如何,当我使用 multiselect插件时我无法显示/隐藏元素.我的代码如下:
I am tryng to show/hide elements in a multiselect dropdown, based on the selection in another multiselect dropdown. Anyway, when I use the multiselect plugin I am not able to show/hide the elements. My code looks like this:
@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部分在这里:
and the javascript part is here:
jQuery(function ($) {
$("select").multiselect();
});
function CompanyDropDownOnChange() {
$("#FlowDropDown option[value=11]").css('display', 'none');
}
样品应该只是隐藏在第二个下拉,当在第一下拉一个公司选择具有ID = 11的流动.
The sample should just hide the flow with id=11 in the second dropdown, when a company in the first dropdown is selected.
推荐答案
我对像您这样的场景进行了一些测试,发现您正在更改错误的元素.
I did some testing with a scenario like yours and found out that you were altering the wrong elements.
function CompanyDropDownOnChange() {
$("input[name=multiselect_FlowDropDown][value=11]").closest('li').css('display', 'none');
}
请参阅此插件,以了解更多详细信息.
Please, refer to this plunker for more details.
这篇关于基于其他多选下拉列表的多选下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!