For some reason my second drop down list is not populating anymore after selecting the first one. I added a default drop-down, and that one is always the one being populated no matter my selection in the first. I’m semi-new to javascript, 90% of my scripting is PHP, so I’m guessing its an error in the way I have it set up (I get PHP and JS syntax confused alot). Just wondering if someone could take a gander and see what I’m missing here.
The Dropdown Menu’s:
[code=html]
<label>Location:</label></td>
<td> <!–document.fileform.location.options–>
<select id=”location” name=”location” size=”1″ onChange=”setOptions(this.options[this.selectedIndex].value);”>
<option value=” “>–Select Page–</option>
<option value=”1″> Documentation </option>
<option value=”2″> Regulatory </option>
<option value=”3″> Meetings </option>
<option value=”4″> Financial </option>
<option value=”5”> Management </option>
</select></td>
</tr>
<!–SECTION SELECT (dynamic, see javascript)–>
<tr>
<td> </td>
<td>
<select id=”section” name=”section” size=”1″>
<option value=” ” >–Choose Page First—</option>
</select>
</td>
</tr>
For some reason the following function always thinks that form has a different value then any of the ones I have predefined in the function.
[code]
function setOptions(chosen)
{
var documentation=new Array ()
documentation[0] = ” Specifications “;
documentation[1] = ” Technical References “;
documentation[2] = ” R&D Specifications “;
var regulatory=new Array ()
regulatory[0] = ” Standards and Procedures “;
regulatory[1] = ” References “;
regulatory[2] = ” Correspondence “;
regulatory[3] = ” Problem Tracking “;
var meetings=new Array ()
meetings[0] = ” General “;
meetings[1] = ” Development Team “;
meetings[2] = ” Program Status “;
meetings[3] = ” Design Review “;
var financial=new Array ()
financial[0] = ” Reports and Agreements “;
financial[1] = ” Data “;
var management=new Array()
management[0] = ” General “;
var section = document.fileform.section;
//end vars
section.options.length = 0;
switch (section)
{
case ((chosen == ” “) || (!chosen) || (chosen = “”)):
section.options[section.options.length] = new Option(‘–Choose Page First–‘, ‘ ‘);
break;
case (chosen == “1”):
for (i=0;i<3;i++)
{
section.options[section.options.length] = new Option(documentation[i], i);
}
break;
case (chosen == “2”):
for (i=0;i<4;i++)
{
section.options[section.options.length] = new Option(regulatory[i], i);
}
break;
case (chosen == “3” ):
for (i=0;i<4;i++)
{
section.options[section.options.length] = new Option(meetings[i], i);
}
break
case (chosen == “4”):
for (i=0;i<2;i++)
{
section.options[section.options.length] = new Option(financial[i], i);
}
break;
case (chosen == “5”):
section.options[section.options.length] = new Option(‘General’, ‘0’);
break;
default:
section.options[section.options.length] = new Option(‘–Default Case–‘, ‘ ‘);
break;
//it always comes up with default
}
}
//end function
Thanks for looking into it.
–T.J.–