if else statements syntax error

Hi,

I am having difficultly with this code...I am sure it has something to do with the semicolon's but I am stumped.

Thanks

function capitalgains()
{
if(document.forms[0].radiobutton1[0].checked)(
  var box = document.forms[0].select.value ;
 document.forms[0].textfield4.value = (box-0);
 )
 else
     { var a = document.forms[0].textfield3.value;
(document.forms[0].textfield4.value = (a-0)/2);
}

   
}
</script>
gweston2003Asked:
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.

WakieCommented:
function capitalgains()
{
if(document.forms[0].radiobutton1[0].checked);
 var box = document.forms[0].select.value;
document.forms[0].textfield4.value = (box-0);
}
else
    {
var a = document.forms[0].textfield3.value;
document.forms[0].textfield4.value = (a-0)/2;
}

   
}
</script>
0
msmalesCommented:
Looks like you're using JavaScript.

qweston2003,
I can easily see your problem there. Your opening and closing brackets of your IF statement are round brackets which should have curly brackets instead.

Wakie's example above also have a syntax error. The problem is the semi-colon after the IF statement header which should have an opening curly bracket.

Martin
0
msmalesCommented:
And by the way, make sure you also have a <script> tag to complement with the closing </script> tag.

Martin
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

gweston2003Author Commented:
Thanks guys
I still can't get ...I put a curly bracket after If and IE tells me it wants a regular bracket...?

Here's what I have now

<script type="text/javascript">
function capitalgains()
{
if{document.forms[0].radiobutton1[0].checked};
var box = document.forms[0].select.value;
document.forms[0].textfield4.value = (box-0);
}
else
   {
var a = document.forms[0].textfield3.value;
document.forms[0].textfield4.value = (a-0)/2;
}

 
}
</script>
0
AndrewKCommented:
no - msmales was talking about this:

function capitalgains()
{
if(document.forms[0].radiobutton1[0].checked)
   {
      var box = document.forms[0].select.value ;
      document.forms[0].textfield4.value = (box-0);
   }
else
   {
      var a = document.forms[0].textfield3.value;
      document.forms[0].textfield4.value = ((a-0)/2);
   }
}


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
gweston2003Author Commented:
This is my first time using this site...I am not sure if I am doing this correctly I should have accepted all three answers...
0
AndrewKCommented:
You should have accepted msmales answer - he meant what I wrote. Mine may have been clearer, but that's what he meant! Equally, you can only accept one answer - just use your judgement as to which answer helped you out the most. If none help, don't accept them (but always be polite and say why!). Also, only accept an answer after you have verified that it really works for you.
0
msmalesCommented:
Looks like Andrew's answer is a LOT clearer than mine :)

Besides, if it were up to me, I would definitely accept Andrew's answer, so don't be modest Andrew! :)
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
Web Languages and Standards

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.