...

View Full Version : Show/hide dropdown based on choice



Yorick
10-14-2006, 07:07 PM
Ok i need some simple code, I hope someone can help me out.

I've got the following dropdown:

<select id="abonnement" name="abonnement">
<option value="">Selecteer soort</option>
<option value="los">Los toestel</option>
<option value="icm">Toestel icm abonnement</option>
</select>

If option "Los toestel" is chosen, I want to hide the following dropdown, and when "Toestel icm abonnemnt is chosem I want to display the following dropdown.


<select id="provider" name="provider">
<option value="">Selecteer een provider</option>
<option value="">Maakt niet uit</option>
</select>

Thanks in advance,
Yorick

boeing747fp
10-14-2006, 07:20 PM
<script type="text/javascript">
function ChangeDropdowns(value){
if(value=="los"){
document.getElementById('provider').style.display='none';
}else if(value=="icm"){
document.getElementById('provider').style.display='block';
}
}
</script>
<select id="abonnement" name="abonnement" onchange="ChangeDropdowns(this.value);">
<option value="">Selecteer soort</option>
<option value="los">Los toestel</option>
<option value="icm">Toestel icm abonnement</option>
</select>
<select id="provider" name="provider">
<option value="">Selecteer een provider</option>
<option value="">Maakt niet uit</option>
</select>

Yorick
10-14-2006, 10:45 PM
It works great! Thanks :D!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum