I have 3 SelectBoxes
, they can have values as 1,2,3
.
Their names are "a","b","c". I only want to reach them using their names.
When I use this function, on first SelectBox's onChange
event,
var source = document.getElementsByName("a")[0];
document.getElementsByName("b")[0].options[source.value].setAttribute("disabled","disabled");
document.getElementsByName("c")[0].options[source.value].setAttribute("disabled","disabled");
And for second SelectBox's onChange event,
var source = document.getElementsByName("b")[0];
document.getElementsByName("c")[0].options[source.value].setAttribute("disabled","disabled");
It works. But if i change firstSelectBox's again... then I cant use the first value which was disabled, but should be enabled now.
I hope I am clear about what i want to do.
Here is the pic:
it doesnt get into for loop...
var optSecond = document.getElementsByName("nameSelectBox16257264317217")[0].options;
for (var i = 1; i < optSecond.length; i++) {
optSecond[i].removeAttribute("disabled");
console.log(optSecond[i].value);
}
var optThird = document.getElementsByName("nameSelectBox162572643286379")[0].options;
for (var i = 1; i < optThird .length; i++) {
optThird[i].removeAttribute("disabled");
console.log(optSecond[i].value);
}
var source = document.getElementsByName("nameSelectBox162572640796915")[0];
document.getElementsByName("nameSelectBox16257264317217")[0].options[source.value].setAttribute("disabled", "disabled");
document.getElementsByName("nameSelectBox162572643286379")[0].options[source.value].setAttribute("disabled", "disabled");