I found the following script somewhere so I can change values to money before
the form is printed. The page works for most people but not some. It worked
fine for me but I get the yellow tri-angle with an exclamation point in the
bottom left part of the window. When I told my IE to display a notification
about every error...it told me there was a problem with line 11.
What is wrong with this?
9 function formatCurrency(strValue)
10 {
11 strValue = strValue.toString().replace(/\$|\,/g,'');
12 dblValue = parseFloat(strValue);
13 blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
14 dblValue = Math.floor(dblValue*100+0.50000000001);
15 intCents = dblValue%100;
16 strCents = intCents.toString();
17 dblValue = Math.floor(dblValue/100).toString();
18 if(intCents<10)
19 strCents = "0" + strCents;
20 for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
21 dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
22 dblValue.substring(dblValue.length-(4*i+3));
23 return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}
error message
Line 11
Char 2
Error 'undefined' is null or not an object
code 0