Is there a way to reload some option values in a select with php or javascript? So when a user changes the value of a "select" the 2 other selects should change from values.
For example: you have to chose how many grown ups are going to travel. (max 6 persons) So you choose 4 When you have chosen the other 2 selects (for kids and baby's) change to the amount that is left (here it's 2).
So when you select a 1 at the kids selection, the baby will change to 1.
I thought it would work with something like this: but I was wrong.
<select name="dpl_volwassenen" id="dpl_volwassenen" onchange="getPersonen(this)">
<script type="text/javascript">
for (i=0; i<=6; i++){
myOption=new Option(i, i);
document.getElementById('dpl_volwassenen').options[i]=myOption;
}
var aantal = 6;
function getPersonen($int_aantal){
aantal = aantal - $int_aantal.value;
for (i=0; i<=aantal; i++){
myOption=new Option(i, i);
document.getElementById($int_aantal.id).dpl_volwassenen.options[i]=myOption;
}
}
</script>
</select></td>
</tr>
<tr>
<td>
<select name="dpl_kinderen" id="dpl_kinderen" onchange="getPersonen(this)">
</select>
</td>
</tr>
<tr>
<td>
<select name="dpl_babys" id="dpl_babys" onchange="getPersonen(this)">
</select>
</td>
</tr>
Does someone has an idea how I could solve this problem?
Thanks so much in advance!