using if and else statements

Hi folks,

  I am having a problem with a snippet of coding in Dreamweaver.
I have a button, which I change the text displayed and shows an image.
I can do this just fine, but when I try to add my "ELSE" section of my coding to flip it back when the user clicks on it again, it phews.
What in the world am I doing wrong??
I did use braces as I ws taught in Javascript, but it still does not work right with the else section.
This works fine without the else section

<script language="javascript">
<!--
function ShowIt()
{
var vElement = document.getElementById('mypics');
var vButtonText = document.forms["page3"].btnSeeIt.value;
if (vButtonText == "See Picture")
    document.forms['page3'].btnSeeIt.value="Hide Picture";
     vElement.style.visibility='visible';
}

//-->
</script>

But when I add the else section it phews..


<script language="javascript">
<!--
function ShowIt()
{
var vElement = document.getElementById('mypics');
var vButtonText = document.forms["page3"].btnSeeIt.value;

if (vButtonText == "See Picture")
    document.forms['page3'].btnSeeIt.value="Hide Picture";
     vElement.style.visibility='visible';
else
    vElement.style.visibility='hidden';
    document.forms['page3'].btnSeeIt.value="See Picture";
     
}

//-->
</script>

bearpawsAsked:
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.

IanaldoCommented:
Just added an extra brackets for the else and if:

function ShowIt()
{
var vElement = document.getElementById('mypics');
var vButtonText = document.forms["page3"].btnSeeIt.value;

if (vButtonText == "See Picture"){
    document.forms['page3'].btnSeeIt.value="Hide Picture";
     vElement.style.visibility='visible';
else{
    vElement.style.visibility='hidden';
    document.forms['page3'].btnSeeIt.value="See Picture";
     }
   }
}

//-->
</script>

Not sure if it will help!!

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
bearpawsAuthor Commented:
that worked, but had to remove one brace
Thank you so much..:)))
IanaldoCommented:
No problem, anytime!

Regards

Ianaldo
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
Adobe Dreamweaver

From novice to tech pro — start learning today.