139
rated 0 times
[
146]
[
7]
/ answers: 1 / hits: 62270
/ 12 Years ago, tue, september 4, 2012, 12:00:00
I try to create a relation/connexion beetwen 2 selectbox
<form id=creation name=creation>
<select name=select01 id=select01>
<option value=01>01</option>
<option value=02>02</option>
<option value=03>03</option>
</select>
<select name=select02 id=select02>
<option value=aa>aa</option>
<option value=bb>bb</option>
<option value=cc>cc</option>
</select>
</form>
I want that my selectbox select02 be disabled at the begening, and when i click on value02 or value03, we enable it, and when we click on value01, disable it.
There is my code js for the moment. I try to adapt it from an other function (radiobutton enabling a selectbox) but it doesn't seem to work. My list is disable at the beging, but the onclick is not working ...
Some body can help me?
var oui = document.creation.select01[0];
document.getElementById(select02).disabled=true;
oui.onclick = function() {
document.getElementById(select02).disabled=false;
}
Ok, so NOW, i'm with this code:
<script>
var oui = document.select01;
document.getElementById(select02 ).disabled=true;
oui.onchange = function(){
document.getElementById(select02 ).disabled=false;
}
</script>
I change the value of my selec01, then my select02 is now enable .. but how can I target only 2 options of my select01 ?
More From » html