Twister
04-07-2003, 08:37 PM
I am new to java. I have made a small script that I feel should work but is not. Can some one take a look at it and tell me what is wrong? The script should average three numbers. When I click on the button to average it tells me that there is an error on the page. I can not find it but once again I am new to java.
<script language=JAVASCRIPT>
<!--
Function add() {
a = document.form1.a.value;
b = document.form1.b.value;
c = document.form1.c.value;
d = a+b+c;
e = d/3;
document.form1.total.value = e
}
//-->
</script>
<FORM name=form1>
<P><B>Average of Three Numbers</b></p>
<p>Enter First Number <input size=5 name=a></p>
<p>Enter Secound Number <input size=5 name=b></p>
<p>Enter Third Number <input size=5 name=c></p>
Results <input maxlength=40 size=5 name=total>
<input onclick=add() type=button value=Average>
<p><colspan=3><input type=reset value=Reset></p>
<script language=JAVASCRIPT>
<!--
Function add() {
a = document.form1.a.value;
b = document.form1.b.value;
c = document.form1.c.value;
d = a+b+c;
e = d/3;
document.form1.total.value = e
}
//-->
</script>
<FORM name=form1>
<P><B>Average of Three Numbers</b></p>
<p>Enter First Number <input size=5 name=a></p>
<p>Enter Secound Number <input size=5 name=b></p>
<p>Enter Third Number <input size=5 name=c></p>
Results <input maxlength=40 size=5 name=total>
<input onclick=add() type=button value=Average>
<p><colspan=3><input type=reset value=Reset></p>