|
i need to have a number put into field1 and displayed in field1 as currency and at the same time be multiplied by 50 and displayed in field2 as currency. Right now i have it were field1 can be displayed as a number then multiplied by 50 and shown in field2 as currency, but when i make field1 display as currency field2 shows $0.00 i think this is due to the fact that the numbers in field1 now have currency symbols in them....... is there a way to make a number be diplayed as currency and multiplied at the same time i will paste the code i'm using thanks
<script language="JavaScript">
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+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);
}
</script>
<script type="text/javascript">
function docomputation(form) {
var result ;
var val = form.Input.value ;
if (val.length==0 || isNaN(val)) {
result = 0 ;
} else {
result = 50 * val ;
}
form.Input2.value = formatCurrency(result.toString()) ;
return 1 ;
}
function formatCurrency(num) {
num = num.replace(/\$|\,/g,'') ;
if (isNaN(num)) {
num = "0" ;
}
sign = (num == (num = Math.abs(num))) ;
num = Math.floor(num*100+0.50000000001) ;
num = Math.floor(num/100).toString() ;
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);
}
</script>
<form id="Calc" name="Calc" method="post" action="" >
<span style="font-family: 'Times New Roman', Times, serif; font-size: 16px; color: #060; padding-left: 110px;">If you want to save </span>
<input onfocus="this.value=''" type="text" value="Enter Amount" id="Calcname" onkeydown="docomputation(this.form)" onkeyup="this.value=formatCurrency(this.value);" style="font-size:14px; color: #060; font-family: 'Times New Roman', Times, serif; text-align: right;" name="Input" size="15" />
<span style="font-family: 'Times New Roman', Times, serif; font-size: 16px; color: #060;">, you</span><br />
<span style="font-family: 'Times New Roman', Times, serif; font-size: 16px; color: #060; padding-left: 100px;">would need to create </span>
<input id="Calcname2" style="font-size:14px; color: #060; font-family: 'Times New Roman', Times, serif; text-align: right;" name="Input2" size="15" type="text" />
<span style="font-family: 'Times New Roman', Times, serif; font-size: 16px; color: #060;"> in new revenue.</span><br />
<div style="padding-bottom:10px; text-align: center;"><span style="font-family: 'Times New Roman', Times, serif; font-size: 10px; color: #060;">* Based on a 2% operating margin.</span></div>
<div style="text-align:center"><span style="font-family: 'Times New Roman', Times, serif; font-size: 16px; color: #060;">VIE can save you at least $100,000.00<br />
starting with our self-funded analysis.<br />
Give us a call today!</span></div>
<div style="text-align:center"><img src="/forum/images/viegraph.png" width="582" height="299"><img name="" src="images/callvieguy.png" width="390" height="231" alt=""></div>
</form>
|
|
|
|
|
|
|
|