kalibballer
07-27-2003, 04:29 AM
how would i round field 4 to 2 decimal places
<html>
<head>
<script language="javascript">
function doCalculate()
{
//with document.form.myForm
with(document.myForm)
{
field3.value = field1.value - field2.value;
field4.value = field2.value / field1.value * 100;
}
}
</script>
</head>
<body>
<form name="myForm">
<input type="text" name="field1" size="20"><br>
<input type="text" name="field2" size="20"><br>
<input type="text" name="field3" size="20"><br>
<input type="text" name="field4" size="20"><br>
<input type="button" value="Calculate" onclick="doCalculate()">
</form>
</body>
</html>
<html>
<head>
<script language="javascript">
function doCalculate()
{
//with document.form.myForm
with(document.myForm)
{
field3.value = field1.value - field2.value;
field4.value = field2.value / field1.value * 100;
}
}
</script>
</head>
<body>
<form name="myForm">
<input type="text" name="field1" size="20"><br>
<input type="text" name="field2" size="20"><br>
<input type="text" name="field3" size="20"><br>
<input type="text" name="field4" size="20"><br>
<input type="button" value="Calculate" onclick="doCalculate()">
</form>
</body>
</html>