<script language="JavaScript">
<!--
function calculate() {
var x= document.Form.x.value
var y = document.Form.y.value
if(x> 0 && y> 0){
var final = x/(y/100*y/100)
document.Form.answer.value = final
if(final < a){
document.Form.meaning.value = "A"
}
if(final > a && final < b){
document.Form.meaning.value = "B"
}
if(final > b && final < c){
document.Form.meaning.value = "C"
}
if(final > d){
document.Form.meaning.value = "D"
}
}
else{
alert("Please Fill form in correctly")
}
}
//-->
</script>
<div class=form2>
<form name="Form">
x: <input type="text" name="x" size="10"><br />
y: <input type="text" name="y" size="10"><br />
<input type="button" value="Calculate" onClick="calculate()"><br />
Answer: <input type="text" name="answer" size="10"><br />
This Means: <input type="text" name="meaning" size="25"><br />
<input type="reset" value="Reset" />
</form>
</div>
I am using the above to calculate based on peoples inputs X and Y...
I am getting the desired answers however is giving a long list of decimal places.
I am looking for a way to round each answer up to a max of 2 decimal places.
Any help would be much appreciated :-)