functionCurrency assistance please

<!-- I have the following in a form, on the local it will provide the calculations not once online though, and won’t perform the formatCurrency at all anytime. I know what I need, just not getting it in the right “language” in the code…/–>

<HTML>
<HEAD>
<META HTTP-EQUIV=“Content-Type” CONTENT=“text/html; charset=windows-1252”>
<META HTTP-EQUIV=“Content-Language” CONTENT=“en-us”>
<TITLE>Worksheet</TITLE>

<SCRIPT LANGUAGE=“JavaScript”>
<!-- Original: Cyanide_7
<!-- Begin
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,‘’);
if(isNaN(num))
num = “0”;
sign = (num == (num = Math.abs(num)));
num = Math.floor(num100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = “0” + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4
i+3))+‘,’+
num.substring(num.length-(4*i+3));
return (((sign)?‘’:‘-’) + ‘$’ + num + ‘.’ + cents);
}
// End –>
</script>

</HEAD>

<BODY background=“…/…/images/logos/backgrounds/0796089L2.jpg”>

<form method=“POST” name=“Worksheet” action=“–WEBBOT-SELF–” onSubmit=“return Worksheet_Validator(this)” language=“JavaScript”>

<table border=“1” width=“1361” height=“574” bordercolor=“#FFFFFF” cellpadding=“0”>

<tr>
<td width=“22” height=“65”> </td>
<td width=“94” height=“65”></td>
<td width=“172” height=“65”><em>Quilt Size:</em></td>
<td width=“598” colspan=“6” height=“65”><i>Enter Quilt Width: </i> <!–webbot
bot=“Validation” S-Display-Name=“Quilt Width” S-Data-Type=“Number”
S-Number-Separators=“,.” B-Value-Required=“TRUE” –> <INPUT NAME=“Product_Quilt_Width” SIZE=5> 
<i>Enter Quilt Length: </i> <!–webbot bot=“Validation”
S-Display-Name=“Quilt Length” S-Data-Type=“Number”
S-Number-Separators=“,.” B-Value-Required=“TRUE” –> <INPUT NAME=“Product_Quilt_Length” SIZE=5>  <p><i>Multiply
Quilt Width by Quilt Length, This is your Total Square Inches</i>
<input type=text name=Total_Square_Inches onblur=“document.Worksheet.Total_Square_Inches.value = document.Worksheet.Product_Quilt_Width.value * document.Worksheet.Product_Quilt_Length.value;” size=“10” READONLY> <br>
</p>

&lt;/td&gt;
&lt;td width="429" height="65"&gt;&nbsp;&lt;/td&gt;

</tr>

&lt;input type="radio" value="Basting Only" name="Quilting" &gt;
  Basting &lt;input type=text name=Quilting_Basting  
  onfocus="document.Worksheet.Quilting_Basting.value = document.Worksheet.Total_Square_Inches.value * .01;" 
  onblur="document.Worksheet.Quilting_Basting.value=formatCurrency(this.form.value);" size="10" value="$0" READONLY&gt;
  4&quot; Grid Only&lt;br&gt;

</BODY>

try using this function



function formatCurrency(num)
{
	if(isNaN(num)) return num;
	
	num *= 1; // convert to number
	num = num.toFixed(2); // round number
	
	var x = num.toString().split('.');
	var x1 = x[0];
	var x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\\d+)(\\d{3})/;
	
	while(rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + thousandSeparator + '$2');
	}
	
	return ('$' + x1 + x2);
}

<!–FrontPage played a game of hide the name of the form… Everytime I changed it when it was saved it reverted back to FrontPage_Form1

I’m not sure why it won’t work with only one line using the onfocus, but had to do two lines and they both would only work with the onfocus first line and the onblur on the second line. A little tweaking but got it to work like this
–/>

<input type=“radio” value=“Basting Only” name=“Quilting” > Basting <input type=text name=Quilting_Basting
onfocus=“document.FrontPage_Form1.Quilting_Basting.value = document.FrontPage_Form1.Total_Square_Inches.value * .01;”
onblur=“document.FrontPage_Form1.Quilting_Basting.value=formatCurrency(this.value);” size=“10” value=“$0” readonly=“readonly”>
4" Grid Only<br>