Making multiple <DIV> visible and hidden

I have a javascript that's supposed to shuffle through several html panels, making some visible and some invisible.  I keep getting failed errors on each of the pages when I hit the buttons connected to the script... anybody see where my problem is?

<script language="JavaScript">
            function doChanger(){
            var a0Panel = document.getElementById('contactpanel');
            var a1Panel = document.getElementById('billingpanel');
            var a2Panel = document.getElementById('categoriespanel');
            var a3Panel = document.getElementById('logosdescriptionspanel');
            var viewvaluekey = document.getElementById('viewidvalidator');
            var viewvalue1 = viewvaluekey.value.ToString();
             if (viewvalue1 == "0"){              
                     a0Panel.style.display = "block";                    
                     a1Panel.style.display = "none";
                     a2Panel.style.display = "none";
                     a3Panel.style.display = "none";}
                     else
               if (viewvalue1 == "1"){
                     a0Panel.style.display = "none";                    
                     a1Panel.style.display = "block";
                     a2Panel.style.display = "none";
                     a3Panel.style.display = "none";}
                     else
                if (viewvalue1 == "2")
                     a0Panel.style.display = "none";                    
                     a1Panel.style.display = "none";
                     a2Panel.style.display = "block";
                      a3Panel.style.display = "none";
                      else
            if (viewvalue1 == "3")
                     a0Panel.style.display = "none";                    
                     a1Panel.style.display = "none";
                     a2Panel.style.display = "block";
                     a3Panel.style.display = "none";
            }
            
      
            function buttonchanger0() { //button should show panel1
            var viewvaluekey0 = document.getElementById("viewidvalidator");
            viewvaluekey0.value = "1";
            doChanger();
            }

            function buttonchanger1() { //button should show panel2
            var viewvaluekey5 = document.getElementById("viewidvalidator");
            viewvaluekey5.value = "1";
            doChanger();
            }

            function buttonchanger2() {  //button should show panel3
            var viewvaluekey2 = document.getElementById("viewidvalidator");
            viewvaluekey2.value = "2";
            doChanger();
            }

            function buttonchanger3() {  //button should show panel 4
            var viewvaluekey3 = document.getElementById("viewidvalidator");
            viewvaluekey3.value = "3";
            doChanger();
            }
            function buttonchanger4() {       //next button
            var viewvaluekey4 = document.getElementById("viewidvalidator");
            var viewvalueint1 = viewvaluekey4.value.ToInt32();
            var viewvalueint2 = viewvalue1 - 1;
            var viewvaluestring1 = viewvalueint2.ToString();
            viewvaluekey4.value = viewvaluestring1;
            doChanger();
            }
</script>
LVL 1
preserver3Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
You have no curly braces after the "if" condition.
So is the next "else" out of sequence:

               if (viewvalue1 == "2")
                   a0Panel.style.display = "none";                    
                   a1Panel.style.display = "none";
                   a2Panel.style.display = "block";
                    a3Panel.style.display = "none";
                    else


0
preserver3Author Commented:
sloppy of me, but after I got the brackets back in, it still doesn't seem to work

function doChanger(){
            var a0Panel = document.getElementById('contactpanel');
            var a1Panel = document.getElementById('billingpanel');
            var a2Panel = document.getElementById('categoriespanel');
            var a3Panel = document.getElementById('logosdescriptionspanel');
            var viewvaluekey = document.getElementById('viewidvalidator');
            var viewvalue1 = viewvaluekey.value.ToString();
             if (viewvalue1 == "0"){              
                     a0Panel.style.display = "block";                    
                     a1Panel.style.display = "none";
                     a2Panel.style.display = "none";
                     a3Panel.style.display = "none";}
                     else
               if (viewvalue1 == "1"){
                     a0Panel.style.display = "none";                    
                     a1Panel.style.display = "block";
                     a2Panel.style.display = "none";
                     a3Panel.style.display = "none";}
                     else
                if (viewvalue1 == "2"){
                     a0Panel.style.display = "none";                    
                     a1Panel.style.display = "none";
                     a2Panel.style.display = "block";
                      a3Panel.style.display = "none";}
                      else
            if (viewvalue1 == "3"){
                     a0Panel.style.display = "none";                    
                     a1Panel.style.display = "none";
                     a2Panel.style.display = "block";
                     a3Panel.style.display = "none";}
            }
            
      
            function buttonchanger0() {
            var viewvaluekey0 = document.getElementById("viewidvalidator");
            viewvaluekey0.value = "1";
            doChanger();
            }

            function buttonchanger1() {
            var viewvaluekey5 = document.getElementById("viewidvalidator");
            viewvaluekey5.value = "1";
            doChanger();
            }

            function buttonchanger2() {
            var viewvaluekey2 = document.getElementById("viewidvalidator");
            viewvaluekey2.value = "2";
            doChanger();
            }

            function buttonchanger3() {
            var viewvaluekey3 = document.getElementById("viewidvalidator");
            viewvaluekey3.value = "3";
            doChanger();
            }
            function buttonchanger4() {
            var viewvaluekey4 = document.getElementById("viewidvalidator");
            var viewvalueint1 = viewvaluekey4.value.ToInt32();
            var viewvalueint2 = viewvalue1 - 1;
            var viewvaluestring1 = viewvalueint2.ToString();
            viewvaluekey4.value = viewvaluestring1;
            doChanger();
            }
0
dakydCommented:
this line is wrong:
  var viewvalue1 = viewvaluekey.value.ToString();

the method should be toString() (lowercase "t").  Change it to this:
  var viewvalue1 = viewvaluekey.value.toString();

Also, don't know if it's intentional or not, but you display the same element for both viewvalue1 == "2" and viewvalue1 == "3".  Shouldn't you show a3Panel for a viewvalue1 == "3"?

Hope that helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
preserver3Author Commented:
thank you both, I was just apparently sloppy....
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.