I have some code that re-sets values in a select box based on what was chosen in a radio group. 2 problems:
1) When I change my radio option, the select box re-sets its values but it jumps from the radio option I selected to the first radio option (try changing from radio 'ADD' to 'DROP' to see).
2) It is not re-setting all the values in the select box. It seems to leave the 1st entry from the old set (when chaging from 'ADD' to 'DROP' the '01' entry should be removed. Am i missing something?
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM name="maint_student_schedule" action="maint_student_schedule" method="post">
<TABLE width="100%" border="0" cellspacing=0 cellpadding=2 id="student_schedule">
<TD ALIGN="CENTER"> <FONT CLASS="PortletText1">
<input type="radio" NAME="sched_type" id="sched_type1" VALUE="ADD" onFocus="redirect(this.id,this.value);" Checked> Add  
</TD>
<TD ALIGN="CENTER"> <FONT CLASS="PortletText1">
<input type="radio" NAME="sched_type" id="sched_type2" VALUE="DEL" onFocus="redirect(this.id,this.value);" > Drop  
</TD>
<TD ALIGN="RIGHT"> <FONT CLASS="PortletText1">
<input type="radio" NAME="sched_type" id="sched_type3" VALUE="CHG" onFocus="redirect(this.id,this.value);" > Change  
</TD>
<TD ALIGN="RIGHT"> <FONT CLASS="PortletText1">
<SELECT name="sched_choice" id="sched_choice1">
<OPTION value=01>01   (07:00-08:44)
<OPTION value=02>02   (08:45-09:25)
<OPTION value=03>03   (09:25-10:10)
<OPTION value=04>04   (10:10-10:55)
<OPTION value=05>05   (10:55-11:40)
<OPTION value=06>06   (11:40-12:25)
<OPTION value=07>07   (12:25-13:09)
<OPTION value=08>08   (13:10-16:00)
</SELECT>
</TD>
</TR>
</TABLE>
<script language="javascript">
function redirect(p_param_id1,p_value) {
temp = document.getElementById(document.maint_student_schedule.sched_choice1.id);
x = document.getElementById(document.maint_student_schedule.sched_choice1.id).options.selectedIndex;
for (m = temp.options.length - 1; m > 0; m--) temp.options[m] = null;
if (p_value =='ADD') {
insertOptionAt(temp, new Option("01 (07:00-08:44)","01"
);
insertOptionAt(temp, new Option("02 (08:45-09:25)","02"
);
insertOptionAt(temp, new Option("03 (09:25-10:10)","03"
);
insertOptionAt(temp, new Option("04 (10:10-10:55)","04"
);
insertOptionAt(temp, new Option("05 (10:55-11:40)","05"
);
insertOptionAt(temp, new Option("06 (11:40-12:25)","06"
);
insertOptionAt(temp, new Option("07 (12:25-13:09)","07"
);
insertOptionAt(temp, new Option("08 (13:10-16:00)","08"
);
} else {
insertOptionAt(temp, new Option("112-001 (ENGLISH 10)","112001"
);
insertOptionAt(temp, new Option("919-002 (PE10/HEALT)","919002"
);
insertOptionAt(temp, new Option("507-003 (BIOLOGY)","507003"
);
insertOptionAt(temp, new Option("507-003 (BIOLOGY)","507003"
);
insertOptionAt(temp, new Option("317-002 (ALG.II (H))","317002"
);
}
return true;}
function insertOptionAt (select,option) {
select.options[select.options.length] = option;
}
</script>
</TBODY>
</FORM>
</TABLE>
</BODY>
</HTML>
1) When I change my radio option, the select box re-sets its values but it jumps from the radio option I selected to the first radio option (try changing from radio 'ADD' to 'DROP' to see).
2) It is not re-setting all the values in the select box. It seems to leave the 1st entry from the old set (when chaging from 'ADD' to 'DROP' the '01' entry should be removed. Am i missing something?
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM name="maint_student_schedule" action="maint_student_schedule" method="post">
<TABLE width="100%" border="0" cellspacing=0 cellpadding=2 id="student_schedule">
<TD ALIGN="CENTER"> <FONT CLASS="PortletText1">
<input type="radio" NAME="sched_type" id="sched_type1" VALUE="ADD" onFocus="redirect(this.id,this.value);" Checked> Add  
</TD>
<TD ALIGN="CENTER"> <FONT CLASS="PortletText1">
<input type="radio" NAME="sched_type" id="sched_type2" VALUE="DEL" onFocus="redirect(this.id,this.value);" > Drop  
</TD>
<TD ALIGN="RIGHT"> <FONT CLASS="PortletText1">
<input type="radio" NAME="sched_type" id="sched_type3" VALUE="CHG" onFocus="redirect(this.id,this.value);" > Change  
</TD>
<TD ALIGN="RIGHT"> <FONT CLASS="PortletText1">
<SELECT name="sched_choice" id="sched_choice1">
<OPTION value=01>01   (07:00-08:44)
<OPTION value=02>02   (08:45-09:25)
<OPTION value=03>03   (09:25-10:10)
<OPTION value=04>04   (10:10-10:55)
<OPTION value=05>05   (10:55-11:40)
<OPTION value=06>06   (11:40-12:25)
<OPTION value=07>07   (12:25-13:09)
<OPTION value=08>08   (13:10-16:00)
</SELECT>
</TD>
</TR>
</TABLE>
<script language="javascript">
function redirect(p_param_id1,p_value) {
temp = document.getElementById(document.maint_student_schedule.sched_choice1.id);
x = document.getElementById(document.maint_student_schedule.sched_choice1.id).options.selectedIndex;
for (m = temp.options.length - 1; m > 0; m--) temp.options[m] = null;
if (p_value =='ADD') {
insertOptionAt(temp, new Option("01 (07:00-08:44)","01"
insertOptionAt(temp, new Option("02 (08:45-09:25)","02"
insertOptionAt(temp, new Option("03 (09:25-10:10)","03"
insertOptionAt(temp, new Option("04 (10:10-10:55)","04"
insertOptionAt(temp, new Option("05 (10:55-11:40)","05"
insertOptionAt(temp, new Option("06 (11:40-12:25)","06"
insertOptionAt(temp, new Option("07 (12:25-13:09)","07"
insertOptionAt(temp, new Option("08 (13:10-16:00)","08"
} else {
insertOptionAt(temp, new Option("112-001 (ENGLISH 10)","112001"
insertOptionAt(temp, new Option("919-002 (PE10/HEALT)","919002"
insertOptionAt(temp, new Option("507-003 (BIOLOGY)","507003"
insertOptionAt(temp, new Option("507-003 (BIOLOGY)","507003"
insertOptionAt(temp, new Option("317-002 (ALG.II (H))","317002"
}
return true;}
function insertOptionAt (select,option) {
select.options[select.options.length] = option;
}
</script>
</TBODY>
</FORM>
</TABLE>
</BODY>
</HTML>