开发者

Removing Items From Dropdown list (client side)

So I have a number of dropdown select list controls populated as part of a repeater. They might contain overlapping data, meaning that the first d d list control will have selections:

a 
b
c

开发者_Python百科Second one:

c
d
e

Third one:

d
e
h

and so on.

So what I would like to do is to srart removing the duplicate items from the reset of drop down controls once the user starts selecting those. I intend to use jQuery for this.


Here, the code is ugly, but at least it's short:

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]; });
});

Live demo: http://jsfiddle.net/bnehe/6/


Try using the jQuery Form Wizard plugin. See: http://plugins.jquery.com/project/formwizard

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜