|
Hi , I am trying to do a simple calculation of two input boxes and output the answer to a third box whilst rounding the numbers to 2 decimal places. Below is my code but I keep getting an error object doesn't support this property or method for line document.stock.getElementById('mus_tot').value = yourTotal;
CODE:
<script type="text/JavaScript">
function round(number,X)
{
X = (!X ? 2 : X);
return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}
function purchase_mus(day1,day2)
{
var yourTotal = round((parseFloat(day1)+parseFloat(day2)),2);
document.stock.getElementById('mus_tot').value = yourTotal;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="stock" method="post" action="/forum/add_to_stock_take.html">
<td width="18%" height="30"><input name="mus_mon" ></td>
<td width="18%" height="30"><input name="mus_tue" >
=</td>
<td width="18%" height="30"><input name="mus_tot" ></td>
<input type="button" width="50" height="20" value="Calculate" onClick="purchase_mus(mus_mon.value,mus_tue.value)"; name="button2">
</form>
|
|
|
|
|
|
|
|