PDA

View Full Version : Adding commas to form results



lukipela
06-06-2008, 09:48 PM
Greetings,

I would like this form to display the results with commas. Unfortunately, I had now javascript experience till yesterday, and even though I've found lots of info on how to add commas in, I just cant seem to get it done. Any help would be greatly appreciated.

Thanks,
Lukipela

Here is my script

<script>
function temp(form)
{
var a = parseFloat(form.price.value, 10);
var b = 0;
if(a > 249999){
b = 250000};
if(a < 250000){
b = a};
var c = 0;
c = (a - b) * .5;
var d = 0;
d = (c *.2)
var e = 0;
e = (b + c + d)
var f = 0;
f = (e * .35)
var g = 0;
g = (a - f)
form.price.value = a.toFixed(2);
form.sec179.value = b.toFixed(2);
form.bonus.value = c.toFixed(2);
form.fyd.value = d.toFixed(2);
form.td.value = e.toFixed(2);
form.savings.value = f.toFixed(2);
form.newprice.value = g.toFixed(2);
}
</script>

And here is the html

<form style="width: 188px">
Enter cost of equipment<br />
<input name="price" value="5000" maxlength="15" size="15" /><input name="calc" value="Calculate" type="BUTTON" onclick="temp(this.form)" /><br />
<br />
<input name="sec179" readonly="" size="15" /><br />
<input name="bonus" readonly="" size="15" /><br />
<input name="fyd" readonly="" size="15" /><br />
<input name="td" readonly="" size="15" /><br />
<input name="savings" readonly="" size="15" /><br />
<input name="newprice" readonly="" size="15" /></form>


Here is a link to it ( hope this is ok to post)

http://www.tdmachinetools.com/tax%20savings.htm