4
I have 3 DropDownList
where they have 4 items with the same valor
(1,2,3,4). I need to respect each DropDownList
do 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 managed to do with 2 Dropdownlist this way:
$(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 do for any of the ddls to get repeat values?
Thanks for the help Lleon.
– Rodrigo Henriques