PDA

Click to See Complete Forum and Search --> : Disable dropdown based on another dropdown's value [RESOLVED]


rockies1
Mar 2nd, 2005, 09:19 AM
I have a page with 2 dropdowns. One is called type and contains One-Time and Recurring. The other is frequency and contains many items.

If a user selects Recurring from type, I want the Frequency dropdown to be available, but if they selected On-Time, I do not want Frequency to be available.

How would I do that?

Thanks!

Psyrus
Mar 3rd, 2005, 08:55 AM
Try this:


<html>
<head>
<title>Disable Drop Down</title>

<script type = "text/javascript">
function disableDrop(){
if(frmMain.sltMain.options[0].selected){
frmMain.sltSecondary.disabled = true;
}
else{
frmMain.sltSecondary.disabled = false;
}
}
</script>
</head>
<body>

<form ID = "frmMain">

<select ID = "sltMain" onchange = "disableDrop();">
<option value = "onetime">One-Time</option>
<option value = "recurring" selected>Recurring</option>
</select>

<select ID = "sltSecondary">
<option value = "1">One</option>
<option value = "2">Two</option>
<option value = "3">Three</option>
<option value = "4">Four</option>
</select>

</form>

</body>
</html>

rockies1
Mar 3rd, 2005, 09:00 AM
That worked perfectly, thank you!

Psyrus
Mar 3rd, 2005, 09:13 AM
Glad that I could help. :)

Don't forget to edit the topic and add [RESOLVED] in the title.