Jump to content

Adding Currency Symbol To Javascript


Recommended Posts

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>


Link to comment
Share on other sites

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>
Link to comment
Share on other sites

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

Link to comment
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...
 Share

×
×
  • Create New...