I have this script, which works fine but has one issue.
I have 2 dropdowns that determine what DIV tag is showing. The first Dropdown shows one of 2 different dropdowns for the 2nd list.
The 2nd list shows/hides one of several forms. The problem is, if I select an item in List1 then select one of the forms in its List2 that form will appear, but if I then go back to LIst1 and select a different item, the form does not disappear as it should, which ends up causing multiple DIVs to be visible on the page.
I'd like the List1 selection change to also reset all the Divs back to "hidden" before it continues to show its selected DIV.
My dropdown event:
<select name="TypeList" onchange="changeForm(this.form.TypeList)">
My code:
function changeForm(what)
{
for (var i=0; i<what.options.length; i++)
{
if (what.options[i].selected)
{
if (document.getElementById)
document.getElementById(what.options[i].value).style.visibility="visible";
document.getElementById(what.options[i].value).style.left="1px";
}
else
{
if (document.getElementById)
document.getElementById(what.options[i].value).style.visibility="hidden";
document.getElementById(what.options[i].value).style.left="800px";
}
}
}
should be equal to:
<select name="TypeList" onchange="changeForm(this)
And other thing, if you have select named - List1 and List2 just do something like this in List1 (assuming that name of List2 is "List2"):
<select name="List1" onchange="changeForm(this)
This should work... i think :)