Click to See Complete Forum and Search --> : display 000.00 format


shanuragu
08-01-2003, 02:22 AM
Hi

I want to dispaly amount in 00(any).00 format .
Here .00 is fixed.
ex.
if amount is 100 it should be displayed as 100.00
if 100.9 it should be displayed as 100.90
if 100.99 it should be displayed as 100.99 itself

please help

shara

Charles
08-01-2003, 04:54 AM
<script type="text/javascript">
<!--
Number.prototype.toReallyFixed = function (l,r) {
if (isNaN(this)) return 'NaN';
var n = Math.abs(this).toFixed(r);
var i;
for (i=0; i<l; i++) {if (Math.abs(this) < i * 10) n = '0' + n};
if (this < 0) n = '-' + n;
return n;
}

alert(Math.PI.toReallyFixed(3,2));
// -->
</script>

Vladdy
08-01-2003, 05:27 AM
If you ever worked with C, you may find this helpful:
http://www.codingforums.com/showthread.php?s=&threadid=23973