ksuwyldkat
07-24-2002, 06:55 PM
I have one combo box in one cell of a table. I want it so that if you select the last option; then the options in another combo box in another cell changes. I have this so far but I keep getting the error: "document.number1.select_2.options" is null or not and object.
Here is what I have so far:
"<"Script Language = "Javascript">
var num_of_cats = 4; // This is the number of instructions, including the first, blank, category.
var option_array = new Array(num_of_cats);
option_array[0] = new Array("N/A",
"N/A");
option_array[1] = new Array("N/A",
"N/A");
option_array[2] = new Array("N/A",
"N/A");
option_array[3] = new Array("-- Select Return --",
"Small Biz",
"Corporate");
function switch_select()
{
{
for (loop = document.number1.select_2.options.length-1; loop > 0; loop--)
{
document.number1.select_2.options[loop] = null;
}
for (loop = 0; loop < option_array[document.number1.select_1.selectedIndex].length; loop++)
{
document.number1.select_2.options[loop] = new Option(option_array[document.number1.select_1.selectedIndex][loop]);
}
document.number1.select_2.selectedIndex = 0;
}
}
/Script
Table detail:
"<"td align="center" >"<"form name='number1'>
"<"font face="arial" size="2">
"<"select name='select_1' size="1" onChange="switch_select();">
"<"option>Please select an instruction
"<"option>Call
"<"option>Click
"<"option>Return
"<"/select>
"<"/form>
"<"/td>
"<"td>
"<"form name='number1'>
"<"select name='select_2' size="1">
"<"option >N/A
"<"/select>
"<"/form>
"<"/td>
Probably something silly I am missing.
Here is what I have so far:
"<"Script Language = "Javascript">
var num_of_cats = 4; // This is the number of instructions, including the first, blank, category.
var option_array = new Array(num_of_cats);
option_array[0] = new Array("N/A",
"N/A");
option_array[1] = new Array("N/A",
"N/A");
option_array[2] = new Array("N/A",
"N/A");
option_array[3] = new Array("-- Select Return --",
"Small Biz",
"Corporate");
function switch_select()
{
{
for (loop = document.number1.select_2.options.length-1; loop > 0; loop--)
{
document.number1.select_2.options[loop] = null;
}
for (loop = 0; loop < option_array[document.number1.select_1.selectedIndex].length; loop++)
{
document.number1.select_2.options[loop] = new Option(option_array[document.number1.select_1.selectedIndex][loop]);
}
document.number1.select_2.selectedIndex = 0;
}
}
/Script
Table detail:
"<"td align="center" >"<"form name='number1'>
"<"font face="arial" size="2">
"<"select name='select_1' size="1" onChange="switch_select();">
"<"option>Please select an instruction
"<"option>Call
"<"option>Click
"<"option>Return
"<"/select>
"<"/form>
"<"/td>
"<"td>
"<"form name='number1'>
"<"select name='select_2' size="1">
"<"option >N/A
"<"/select>
"<"/form>
"<"/td>
Probably something silly I am missing.