Ok, I’d been working on this code for awhile with BigMoosie’s help. It’s been rather unco-operative…
Basically, I have a <select> menu that changes based on the selection in the previous menu. When the user submits the form the values are e-mailed to me.
The script that changes the <select>
[code=php]
function ldMenu(mySubject, doKeep) {
var Indx=mySubject;
with (document.application.occ)
{
if (Indx==0)
{
options[0]=new Option(” – – Class – – “,””);
}
if (Indx==1)
{
options[0]=new Option(” – – Class – – “,””);
options[1]=new Option(“Druid”,”Druid”);
options[2]=new Option(“Hunter”,”Hunter”);
options[3]=new Option(“Preist”,”Preist”);
options[4]=new Option(“Rogue”,”Rogue”);
options[5]=new Option(“Warrior”,”Warrior”);
options.length=5;
}
if (Indx==2)
{
options[0]=new Option(” – – Class – – “,””);
options[1]=new Option(“Mage”,”Mage”);
options[2]=new Option(“Paladin”,”Paladin”);
options[3]=new Option(“Preist”,”Preist”);
options[4]=new Option(“Rogue”,”Rogue”);
options[5]=new Option(“Warrior”,”Warrior”);
options[6]=new Option(“Warlock”,”Warlock”);
options.length=7;
}
if (Indx==3)
{
options[0]=new Option(” – – Class – – “,””);
options[1]=new Option(“Hunter”,”Hunter”);
options[2]=new Option(“Paladin”,”Paladin”);
options[3]=new Option(“Preist”,”Preist”);
options[4]=new Option(“Rogue”,”Rogue”);
options[5]=new Option(“Warrior”,”Warrior”);
options.length=6;
}
if (Indx==4)
{
options[0]=new Option(” – – Class – – “,””);
options[1]=new Option(“Mage”,”Mage”);
options[2]=new Option(“Rogue”,”Rogue”);
options[3]=new Option(“Warlock”,”Warlock”);
options[4]=new Option(“Warrior”,”Warrior”);
options.length=5;
}
if (doKeep!=null) application.occ.options[doKeep].selected=true;
else application.occ.options[0].selected=true;
}
}
The important/broken parts of the form
[code=php]
<form onsubmit=”storeinfo(); return true;” action=”apply.php” method=”POST” name=”application”>
<select name=”race” onChange=”ldMenu(this.selectedIndex);” size=”1″>
<option value =none selected=”selected”> – – Race – – </option>
<option value =”Night Elf”>Night Elf</option>
<option value =”Human”>Human</option>
<option value =”Dwarf”>Dwarf</option>
<option value =”Gnome”>Gnome</option>
</select>
<select name=”occ” size=”1″>
<option selected=”selected”> – – Class – – </option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select>
Now, there are 2 problems.
1.) If someone makes a mistake they get an error page that indicates what field they left blank and are provided a link to go back to the form. All the options in the form are remembered, except they have to reselect their class. I’d like it to remember their class
2.) If you select Night Elf the last option, Warrior, wont display in the second <select> menu
Everything else about the script works right now and I’d be in hog heaven if I could get these last 2 bugs worked out
A live version of this is posted at the site, [url]http://www.kotguild.net/apply.php