Google has plenty of results for similar problems, but after a day of searching, I still cannot figure this out.
I have a dropdown menu with six choices.
I have a switch statement with which I would like to evaluate the chosen item in the dropdown list to determine which document.write statements to execute.
Please keep in mind that the variables in the document write statements are defined before this block of code picks up. Also, the opening tag exists much earlier in the code as well.
Thank you for your help.
function handleSelect(account)
{
//var selectedAcct = document.getElementByName("acctTypes");
document.write("<table><tbody>");
switch(account)
{
case "View All":
document.write(savings);
document.write(checking);
document.write(moneymkt);
document.write(cdjumbo);
document.write(cdsmall);
document.write(iras);
break;
case "Certificates of Deposit (CDs)":
document.write(cdjumbo);
document.write(cdsmall);
break;
case "Individual Retirement Account (IRA)":
document.write(iras);
break;
case "Money Market":
document.write(moneymkt);
break;
case "Savings":
document.write(savings);
break;
case "Checking":
document.write(checking);
break;
default:
document.write(savings);
document.write(checking);
document.write(moneymkt);
document.write(cdjumbo);
document.write(cdsmall);
document.write(iras);
}
document.write("</tbody></table>");
}
</script>
<form name="acctTypes" action=" ">
<select name="acctDropdown" id="acctDropdown" onLoad="handleSelect(this.value)" onChange="handleSelect(this.value)">
<option value="View All" selected>View All</option>
<option value="Certificates of Deposit (CDs)">Certificates of Deposit (CDs)</option>
<option value="Individual Retirement Account (IRA)">Individual Retirement Account (IRA)</option>
<option value="Money Market">Money Market</option>
<option value="Savings">Savings</option>
<option value="Checking">Checking</option>
</select>
</form>