Jump to content
Sign in to follow this  
zalipresents

Javascript Calculate Not Adding Past The Decimal

Recommended Posts

Please help...i'm using the below script in a details page to calculate "Show Gross" and the formula is not calculating any numbers past the decimals.  I've tried changing the "total" to "total.toFixed(2)" in a variety of ways and it didn't help...also tried adding in ".toPrecision()" and it didn't work.  I can get the end cell to have 2 spaces with ".toFixed(2)", however the calculation does not calculate anything past the decimal.  Didn't realize this was an issue till just now & I am in a bind...please help:)  It feels like I need to tell the formula to calculate the numbers past the decimals, however I'm not sure on how to do that.

 

<SCRIPT LANGUAGE="JavaScript">
 
 function calculate()
 {
 var Settle_ADV_Gross = isNaN((parseInt(document.getElementById("EditRecordSettle_ADV_Gross").value)))?0:(parseInt(document.getElementById("EditRecordSettle_ADV_Gross").value));
 
   var Settle_DOS_Gross = isNaN((parseInt(document.getElementById("EditRecordSettle_DOS_Gross").value)))?0:(parseInt(document.getElementById("EditRecordSettle_DOS_Gross").value));
 
 var Settle_Walk_Up_Gross = isNaN((parseInt(document.getElementById("EditRecordSettle_Walk_Up_Gross").value)))?0:(parseInt(document.getElementById("EditRecordSettle_Walk_Up_Gross").value));
 
 
   var total= Settle_Walk_Up_Gross + Settle_DOS_Gross + Settle_ADV_Gross;
 
document.getElementById("mypage").innerHTML=' $'+total ;
document.getElementById("EditRecordSettle_Show_Gross").value=total ;
 
 }
 
 
document.getElementById("EditRecordSettle_Walk_Up_Gross").onchange=calculate;
document.getElementById("EditRecordSettle_DOS_Gross").onchange=calculate;
 
document.getElementById("EditRecordSettle_ADV_Gross").onchange=calculate;
calculate();
</SCRIPT>
</span></strong>

Share this post


Link to post
Share on other sites

Hello zalipresents,

 

I would recommend you to use calculated field: 

IsNull([@field:Settle_Walk_Up_Gross],0)+IsNull([@field:Settle_DOS_Gross],0)+IsNull([@field:Settle_ADV_Gross],0)

and choose the format of results of your calculated field.

 
Hope it helps.

post-17557-0-38784400-1442240585_thumb.j

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...