I have 3 DropDownList
where they have 4 items with the same valor
(1,2,3,4). I need to respect that every DropDownList
does not repeat the value selected in the others.
Example:
ddl0= 1
ddl1= 2 (não permitiria escolher os valores 1 e 3)
ddl2= 3 (não permitiria escolher os valores 1 e 2)
*ddl= DropDownList
I was able to do with 2 DropDownList like this:
$(document).ready(function () {
$("#ddl0").on('change', function () {
if ($(this).val() == '1') {
$("#ddl1 option[value='1']").prop("disabled", true);
$("#ddl1 option[value='2']").prop("disabled", false);
$("#ddl1 option[value='3']").prop("disabled", false);
$("#ddl1 option[value='4']").prop("disabled", false);
} else if ($(this).val() == '2') {
$("#ddl1 option[value='1']").prop("disabled", false);
$("#ddl1 option[value='2']").prop("disabled", true);
$("#ddl1 option[value='3']").prop("disabled", false);
$("#ddl1 option[value='4']").prop("disabled", false);
} else if ($(this).val() == '3') {
$("#ddl1 option[value='1']").prop("disabled", false);
$("#ddl1 option[value='2']").prop("disabled", false);
$("#ddl1 option[value='3']").prop("disabled", true);
$("#ddl1 option[value='4']").prop("disabled", false);
} else if ($(this).val() == '4') {
$("#ddl1 option[value='1']").prop("disabled", false);
$("#ddl1 option[value='2']").prop("disabled", false);
$("#ddl1 option[value='3']").prop("disabled", false);
$("#ddl1 option[value='4']").prop("disabled", true);
}
});
});
Now entering with a third DropDownList. How could I make any of the ddls get repeated values?