DH
Programmer
- Dec 8, 2000
- 168
I have the following sample code to calculate a total.
It works great, but for example if you enter the number "9" in the text box and then tab out so the onblur will take effect, the total is displayed with many decimal places.
I do not work with html much and would like to know how I can I round this to always show 2 decimal places to the right?
<html>
<head>
</head>
<body>
<form name="form1">
Quantity <input type="text"name="qty"onblur="document.form1.total.value=document.form1.qty.value*99.95+4.95";/>
<input type="text" name="total"/> Total
</form>
</body>
</html>
It works great, but for example if you enter the number "9" in the text box and then tab out so the onblur will take effect, the total is displayed with many decimal places.
I do not work with html much and would like to know how I can I round this to always show 2 decimal places to the right?
<html>
<head>
</head>
<body>
<form name="form1">
Quantity <input type="text"name="qty"onblur="document.form1.total.value=document.form1.qty.value*99.95+4.95";/>
<input type="text" name="total"/> Total
</form>
</body>
</html>