PDA

View Full Version : Help with a <select> script



anthropos9
08-15-2007, 02:13 PM
I'm trying to get a script to work where when a person selects an option from a dropdown <select> list more options appear. At present it doesn't even look like the browser is listening for the event. You can see it live at: http://ccms.cteens.org/admin/dev/admin.php?id=addevent

Here is the code:

the html

<select name="the_repeat" onchange="showrepeat(window.document.add_event.the_repeat.selectIndex.value);">
<option value="0">No Repeat/Daily</option>
<option value="2">Weekly</option>
<option value="3">Monthly</option>
</select>

the js


function showrepeat(i) {
var a = 'weekly_repeat';
var b = 'monthly_repeat';
if (document.getElementById) {
var abra = document.getElementById(a).style;
var kadabra = document.getElementById(b).style;
if (i == 0) {
abra.display = "none";
kadabra.display = "none";
} else if (i == 1) {
abra.display = "block";
kadabra.display = "none";
} else if (i == 2) {
abra.display = "none";
kadabra.display = "block";
}
return true;
} else {
return true;
}
}

Thanks for your help.

jscheuer1
08-15-2007, 03:55 PM
See:

http://www.dynamicdrive.com/dynamicindex1/chainedmenu/index.htm

and:

http://www.dynamicdrive.com/forums/showthread.php?t=11585