Pretty simple script. I want it to change the contents of a 2nd pulldown with regard to the first.
This function works:
function changePulldown() {
switch (document.join_form.tline.selectedIndex) {
case 0: document.join_form.tstop.options[0] = new Option ("Packard's Corner", "PKC");
break;
case 1: document.join_form.tstop.options[0] = new Option ("MIT", "MIT");
break;
default:
break;
}
}
This doesn't:
function changePulldown() {
var RedLineOptions = new Array(3);
var GreenLineOptions = new Array(3);
GreenLineOptions[0] = new Option ("Packard's Corner", "PKC");
RedLineOptions[0] = new Option ("MIT", "MIT");
switch (document.join_form.tline.selectedIndex) {
case 0: document.join_form.tstop.options = GreenLineOptions;
break;
case 1: document.join_form.tstop.options = RedLineOptions;
break;
default:
break;
}
}
I haven't done object oriented programming in a while, but I'd like to create the array of options first, then assign according to the switch statement.
Also, bonus points for anyone who can tell me how to create these arrays ONCE and have the function use the created arrays, no matter how many times the function is called.
This function works:
function changePulldown() {
switch (document.join_form.tline.selectedIndex) {
case 0: document.join_form.tstop.options[0] = new Option ("Packard's Corner", "PKC");
break;
case 1: document.join_form.tstop.options[0] = new Option ("MIT", "MIT");
break;
default:
break;
}
}
This doesn't:
function changePulldown() {
var RedLineOptions = new Array(3);
var GreenLineOptions = new Array(3);
GreenLineOptions[0] = new Option ("Packard's Corner", "PKC");
RedLineOptions[0] = new Option ("MIT", "MIT");
switch (document.join_form.tline.selectedIndex) {
case 0: document.join_form.tstop.options = GreenLineOptions;
break;
case 1: document.join_form.tstop.options = RedLineOptions;
break;
default:
break;
}
}
I haven't done object oriented programming in a while, but I'd like to create the array of options first, then assign according to the switch statement.
Also, bonus points for anyone who can tell me how to create these arrays ONCE and have the function use the created arrays, no matter how many times the function is called.