从下拉列表中删除项目(客户端)

时间:2011-02-10 21:03:01

标签: jquery asp.net

所以我有许多下拉选择列表控件作为转发器的一部分填充。它们可能包含重叠数据,这意味着第一个d d列表控件将有选择:

a 
b
c

第二个:

c
d
e

第三个:

d
e
h

等等。

所以我想做的是在用户开始选择那些后,从重置下拉控件中删除重复的项目。我打算为此使用jQuery。

2 个答案:

答案 0 :(得分:1)

在这里,代码很难看,但至少它很简短:

var selects = $('select');

selects.change(function() {
    var vals = {};    
    selects.each(function() { vals[this.value] = true; }).get();
    selects.not(this).children().not(':selected').not(':first-child')
        .each(function() { this.disabled = vals[this.value]; });
});

现场演示: http://jsfiddle.net/bnehe/6/

答案 1 :(得分:0)

尝试使用jQuery Form Wizard插件。请参阅:http://plugins.jquery.com/project/formwizard