|
problem with Math.round
Hi
I have tried various methods to introduce a Mathround function into the code below without success.
I am looking for the result to return an answer to 2 decimal places.
Any thoughts.
<link rel="stylesheet" type="text/css">
<style>
div
{
text-align: right;
padding: 1px;
margin: 1px;
color: #006666;
font-family: arial;
font-size:28pt;
font-weight:700;
background-color:
}
h1
{
text-align: right;
padding: 1px;
margin: 1px;
color: #006666;
font-family: arial;
font-size:9pt;
font-weight:
background-color:
}
</style>
<script type="text/javascript">
function calculate(inputId, outputId)
{
A = document.getElementById(inputId).value
outDiv = document.getElementById(outputId);
B =(parseInt(A) * 1);
//alert(A);
D = (parseInt(B) * 1);
if ( B <= 19)
{
tax1 = '**.**';
}
else if (B <= 30)
{
tax1 = (B * 3.95) * 1;
}
else if (B <= 40)
{
tax1 = (B * 3.75) * 1;
}
else if (B <= 50)
{
tax1 = (B * 3.70) * 1;
}
else if (B <= 60)
{
tax1 = (B * 3.55) * 1;
}
else if (B <= 70)
{
tax1 = (B * 3.40) * 1;
}
else if (B <= 80)
{
tax1 = (B * 3.25) * 1;
}
else if (B <= 90)
{
tax1 = (B * 3.10) * 1;
}
else if (B <= 100)
{
tax1 = (B * 2.95) * 1;
}
else if (B <= 150)
{
tax1 = (B * 2.80) * 1;
}
else if (B <= 200)
{
tax1 = (B * 2.65) * 1;
}
else
{
tax1 = (B * 2.60) * 1;
}
outDiv.innerHTML= '£'+tax1;
}
</script>
</HEAD>
<BODY>
<p style="margin-left: 3">
<h1 style="text-align: left">Enter Quantity (sq m)
<!--webbot bot="Validation" s-data-type="Number" s-number-separators=",." b-value-required="TRUE" i-minimum-length="2" i-maximum-length="3" s-validation-constraint="Greater than or equal to" s-validation-value="20" s-validation-constraint="Less than or equal to" s-validation-value="999" --><INPUT id='inputA' NAME="text1" size="1" value="20" maxlength="3" />
<INPUT TYPE="button" VALUE="price" onClick="calculate('inputA', 'outputA')" style="color: #006666; font-family: Arial; font-size: 10px; position:relative; width:100; height:25"/></h1>
</p>
<div id='outputA' style="width: 0; height: -1"> </div>
<p style="margin-left: 3">
<h1 style="text-align: left">Enter Quantity (sq m)
<!--webbot bot="Validation" s-data-type="Number" s-number-separators=",." b-value-required="TRUE" i-minimum-length="2" i-maximum-length="3" s-validation-constraint="Greater than or equal to" s-validation-value="20" s-validation-constraint="Less than or equal to" s-validation-value="999" --><INPUT id='inputB' NAME="text1" size="1" value="20" maxlength="3" />
<INPUT TYPE="button" VALUE="price" onClick="calculate('inputB', 'outputB')" style="color: #006666; font-family: Arial; font-size: 10px; position:relative; width:100; height:25"/></h1>
</p>
<div id='outputB' style="width: 0; height: -1"> </div>
<p style="margin-left: 3">
<h1 style="text-align: left">Enter Quantity (sq m)
<!--webbot bot="Validation" s-data-type="Number" s-number-separators=",." b-value-required="TRUE" i-minimum-length="2" i-maximum-length="3" s-validation-constraint="Greater than or equal to" s-validation-value="20" s-validation-constraint="Less than or equal to" s-validation-value="999" --><INPUT id='inputC' NAME="text1" size="1" value="20" maxlength="3" />
<INPUT TYPE="button" VALUE="price" onClick="calculate('inputC', 'outputC')" style="color: #006666; font-family: Arial; font-size: 10px; position:relative; width:100; height:25"/></h1>
</p>
<div id='outputC' style="width: 0; height: -1"> </div>
</BODY>
</HTML></code></p>
</body>
</font>
</html>
|