I have about 10 select boxes added to a form using a loop. All with the same number of options.
<?php
for($i=1; $i<11; $i++){
?>
<select name="doc[]"; id="doc<?php echo $i?>"; autocomplete="off";
onchange='disable()' required>
<option value="none" disabled selected>Select</option>
<option value=0>A</option>
<option value=1>B</option>
<option value=2>C</option>
<option value=3>D</option>
<option value=4>E</option>
<option value=5>F</option>
<option value=6>G</option>
<option value=7>H</option>
<option value=8>I</option>
</select>
<?php
}
?>
I want if I select first option in first select box, the next select box should not have that option. In pure Javascript, not Jquery.
I have tried writing something like:
function disable(){
for(var i=1; i<9; i++){
var val = document.getElementById('doc'+i).value;
document.getElementById("doc"+(i+1)).options[val].disabled =
true;
}
}
But it is not working as I expected.