Jennifer
Go to my javascript page for a library of formatting functions and
example of usage.
// Round the decimal place to a maximum of two digits.
var FixedDecimalsA1 = (FixDecimalsA1 * 100);
var FixedDecimalsA2 = Math.round(FixedDecimalsA1);
var FixedDecimalsA3 = (FixedDecimalsA2 / 100);
var FixedDecimalsB1 = (FixDecimalsB1 * 100);
var FixedDecimalsB2 = Math.round(FixedDecimalsB1);
var FixedDecimalsB3 = (FixedDecimalsB2 / 100);
// If the number of decimal places in the dollar amounts is only 1 then
add a zero to it to
// make it a conventional dollar amount.
var strFixedDecimalsA3 = FixedDecimalsA3.toString();
var FixedDecimalsA3Test = strFixedDecimalsA3.indexOf('.');
if (FixedDecimalsA3Test != "-1") {
if (strFixedDecimalsA3.length != FixedDecimalsA3Test + 3) {
FixedDecimalsA3 = FixedDecimalsA3 + "0";
}
}
var strFixedDecimalsB3 = FixedDecimalsB3.toString();
var FixedDecimalsB3Test = strFixedDecimalsB3.indexOf('.');
if (FixedDecimalsB3Test != "-1") {
if (strFixedDecimalsB3.length != FixedDecimalsB3Test + 3) {
FixedDecimalsB3 = FixedDecimalsB3 + "0";
}
}
// Plug in the amounts in the appropriate fields.
document.GetInfo.Life_Amount2.value = FixedDecimalsA3;
document.GetInfo.Life_Cost.value = FixedDecimalsB3;
}
Hope that helps.
Lori
JG wrote in message <38BDE920...@home.com>...
Seems a little arduous!!!
Here's what I wrote and use:
function toCurrency(value){
value=Math.round((value+0)*100);
value=value+"";
var l=value.length;
var m=l-2;
var first=value.substring(0,m);
var last=value.substring(m);
var f="";
if(l<2){f="0";};
return first+"."+f+last;
}
It'll add a zero in front of .49 to make it 0.49 .
But, if I were to do it over, I would use whatever Jerry Park has!
Jeff