Hi there,
I need to have my form round my calculated totals and tax field to .00 (two decimal places only). I understand that it isn't easy to do, due to a JS bug with Math.round
It is giving me quite a headache.%-( Does anyone know how to do this? Help!!!!
this what i've tried:
<code>
<script language="javascript">
function format (expr, decplaces) {
var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces))
while (str.length <= decplaces){
str = "0" + str
}
var decpoint = str.length - decplaces
return str.substring(0, decpoint) + "." + str.substring(decpoint,str.lenght);
}
function dollarize (expr){
return "$" + format(expr,2)
}
</script>
</code>
I tried changing the Math.pow(10, decplaces) to use 2 instead but to no avail. What do you think?
Thanks as always,
DES >:O>
I need to have my form round my calculated totals and tax field to .00 (two decimal places only). I understand that it isn't easy to do, due to a JS bug with Math.round
It is giving me quite a headache.%-( Does anyone know how to do this? Help!!!!
this what i've tried:
<code>
<script language="javascript">
function format (expr, decplaces) {
var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces))
while (str.length <= decplaces){
str = "0" + str
}
var decpoint = str.length - decplaces
return str.substring(0, decpoint) + "." + str.substring(decpoint,str.lenght);
}
function dollarize (expr){
return "$" + format(expr,2)
}
</script>
</code>
I tried changing the Math.pow(10, decplaces) to use 2 instead but to no avail. What do you think?
Thanks as always,
DES >:O>