troubleshooting Question

Java script - show/hide DIV tags based on dropdown selection

Avatar of Zakoriz
Zakoriz asked on
10 Comments1 Solution5148 ViewsLast Modified:
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)

                if (document.getElementById)
Pawel Witkowski
Senior Javascript Developer
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros