• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 79
  • Last Modified:

javascript (asp) code syntax error

I have this javascript which has a syntax error, but I can't seem to find it.  Can someone help?

if (document.form1.AddItem1Amount.value > "0")
      {document.form1.AddItem1MarginPercent.value=+(parseFloat(document.form1.AddItem1AmountExt.value-parseFloat(document.form1.AddItem1CostExt.value))/+parseFloat(document.form1.AddItem1AmountExt.value);
      document.form1.AddItem1MarginPercent.value=+(Math.round(document.form1.AddItem1MarginPercent.value*1000))/10};
    else document.form1.AddItem1MarginPercent.value = "0";
0
drelinger
Asked:
drelinger
1 Solution
 
Tom BeckCommented:
Maybe this is what you want, but honestly, it's hard to understand the intended outcome with operators like "/+" and "=+".
if (document.form1.AddItem1Amount.value > "0"){
	document.form1.AddItem1MarginPercent.value += (parseFloat(document.form1.AddItem1AmountExt.value - parseFloat(document.form1.AddItem1CostExt.value))) / parseFloat(document.form1.AddItem1AmountExt.value);
    document.form1.AddItem1MarginPercent.value += (Math.round(document.form1.AddItem1MarginPercent.value*1000))/10;
} else { 
   document.form1.AddItem1MarginPercent.value = "0";
}

Open in new window

0
 
Rainer JeschorCommented:
Hi,
not sure about your calculation (the additional + signs) - could you perhaps explain in words what you want to have calculated?
if (document.form1.AddItem1Amount.value > "0")
{
	document.form1.AddItem1MarginPercent.value += (parseFloat(document.form1.AddItem1AmountExt.value)-parseFloat(document.form1.AddItem1CostExt.value))/parseFloat(document.form1.AddItem1AmountExt.value);
	document.form1.AddItem1MarginPercent.value =+(Math.round(document.form1.AddItem1MarginPercent.value*1000))/10;
}
else 
{
	document.form1.AddItem1MarginPercent.value = "0";
}

Open in new window


HTH
Rainer
0
 
Brian TaoSenior Business Solutions ConsultantCommented:
Without guessing what you're trying to achieve, the syntax error came from the extra ";" following the /10}.
You should move the ";" inside the "}" and make it /10;}
0
 
drelingerAuthor Commented:
Thanks - formula works - might be a bit unorthodox, but results are good. thanks for helping.
0
 
Brian TaoSenior Business Solutions ConsultantCommented:
Thanks for the points.
0
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now