dexter
dexter

Reputation: 7223

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

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.

Upvotes: 0

Views: 1100

Answers (2)

Šime Vidas
Šime Vidas

Reputation: 186103

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/

Upvotes: 1

aendra
aendra

Reputation: 5346

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

Upvotes: 0

Related Questions