根据ASP MVC中另一个下拉列表中选择的项目从下拉列表中删除项目 [英] Remove an item from a dropdownlist based on the item that is selected in another dropdownlist in ASP MVC
问题描述
我是asp.net mvc的新手,我可以知道如何检查下一个下拉列表中是否存在下拉值,如果存在,则删除该值,如果没有值保留在下拉列表中。
例如:我在下拉选择中有奶酪,巧克力,草莓,然后我选择奶酪,所以我希望从下一个下拉选项中删除奶酪。我正在使用的下拉列表是剑道。谢谢。
下面的代码在视图中
Hi , I am new to asp.net mvc , May I know how can I check if the dropdown value is existed in the previous dropdown, if exist then remove the value , if not have the value remain at the dropdown.
Eg: I have cheese , chocolate , strawberry in the dropdown selection , then I select cheese , so I would like cheese to be remove from the next dropdown selection. The dropdown I am using is kendo. Thank you.
The code below in under view
<select class="form-control "
name="Choice[@ViewBag.CakeIndex].Category">
@foreach (var flavor in ViewBag.Flavour)
{
<option value="@flavor.id">@flavor.name</option>
}
</select>
我尝试了什么:
我曾尝试使用 cakes.Items.Remove (味道);
但我不确定应该使用哪个变量来删除它
What I have tried:
I had tried using cakes.Items.Remove(flavor);
but i am unsure which variable should I use to remove it
推荐答案
('select#select1')。on('change',function(e){
var optionSelected =
('select#select1').on('change', function (e) {
var optionSelected =
(option:selected,this );
var valueSelected = this.value;
var exists = false;
("option:selected", this);
var valueSelected = this.value;
var exists = false;
这篇关于根据ASP MVC中另一个下拉列表中选择的项目从下拉列表中删除项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!