zalipresents Posted August 19, 2015 Report Share Posted August 19, 2015 I need to be able to tell this code to display as a currency at times instead of just a value. This code is adding up a few different cells when the user changes cells. Can you let me know where in the code that should be added? Thanks so much! <div id="mypage"> </div> <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_Walk_Up_Gross").onchange=calculate; document.getElementById("EditRecordSettle_DOS_Gross").onchange=calculate; document.getElementById("EditRecordSettle_ADV_Gross").onchange=calculate; calculate(); </SCRIPT> </span></strong> Quote Link to comment Share on other sites More sharing options...
Aurora Posted August 19, 2015 Report Share Posted August 19, 2015 Hello Zalipresents. You can add the following line + ' $' in this part of your script , so the script will be as follows: document.getElementById("mypage").innerHTML=total+ ' $' ; I hope this helps you! Aurora Quote Link to comment Share on other sites More sharing options...
zalipresents Posted August 19, 2015 Author Report Share Posted August 19, 2015 It does help, now how do I get the $ to show up before the total? The code below gets added at a point where it shows up after the calculation. <div id="Show_Net"> </div> <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 Settle_Door_Deductions = isNaN((parseInt(document.getElementById("EditRecordSettle_Door_Deductions").value)))?0:(parseInt(document.getElementById("EditRecordSettle_Door_Deductions").value)); var total= Settle_Walk_Up_Gross + Settle_DOS_Gross + Settle_ADV_Gross - Settle_Door_Deductions; document.getElementById("Show_Net").innerHTML=total + ' $'; } document.getElementById("EditRecordSettle_Walk_Up_Gross").onchange=calculate; document.getElementById("EditRecordSettle_DOS_Gross").onchange=calculate; document.getElementById("EditRecordSettle_ADV_Gross").onchange=calculate; document.getElementById("EditRecordSettle_Door_Deductions").onchange=calculate; calculate(); </SCRIPT> Quote Link to comment Share on other sites More sharing options...
Aurora Posted August 19, 2015 Report Share Posted August 19, 2015 Hello Zalipresents. I am glad it helped. If you want to have a currency sign before the number add the following line ' $' + in this part of your script , so the script will be as follows: document.getElementById("Show_Net").innerHTML=' $'+total ; Aurora Quote Link to comment Share on other sites More sharing options...
Kurumi Posted June 24, 2022 Report Share Posted June 24, 2022 Hi! You can also check this updated post: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.