I am new to JavaScript and have what may be a very simple and easy question to most. I am writing a simple block of code that I need to display dollar amounts with 2 decimals for change. For example instead of displaying the number 5, I need it to display 5.00. How can I do this? Any help will be greatly appreciated.
jobojo 0
Light Poster
Recommended Answers
Jump to Posthello see this code:
it will print 200 as 200.00<script language="javascript"> function CurrencyFormatted(amount) { var i = parseFloat(amount); if(isNaN(i)) { i = 0.00; } var minus = ''; if(i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .005) * 100); …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.