Hi,
I am new to javascript and I am attempting to output to two decimal places as its currency.
As an example it currently outputs as 127.1 instead of 127.10.
Can anyone look at the snippet of code and show me how please?
function fixNums(value)
{
var raise = Math.pow(10,2);
value = Math.round(value * raise) / raise;
return value;
}
function calcCost(frm)
{
var totalArea = ((frm.area1width.value * frm.area1length.value);
var totalCostSand = totalArea * sandCost;
frm.totalCostSand.value =fixNums(totalCostSand);
}
<p style="text-align: right;">cost for sanding £
<input name="totalCostSand" type="text" class="input" style="width: 50px;" readonly="readonly" />
</p>
thanks


Reply With Quote

Bookmarks