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

编程入门 行业动态 更新时间:2024-10-27 00:29:37
本文介绍了基于其他多选下拉列表的多选下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试根据另一个多选下拉列表中的选择来显示/隐藏多选下拉列表中的元素.无论如何,当我使用 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.

更多推荐

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

本文发布于:2023-08-05 17:06:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1306849.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多选   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!