|
↑
Calculators >>>
One of geometry's most useful formulas, the Pythagorean Theorem, can be applied to the numbers you enter in JavaScript! Just enter 'A' and 'B' and the script solves for 'C'.
Add the below code to the <body> section of your page:
<script
language="javascript"
type="text/javascript">
function
solvepy(form)
{
a
=
parseInt(form.a.value);
b
=
parseInt(form.b.value);
form.c.value
=
Math.sqrt(a*a
+
b*b);
}
</script>
<form>
The Pythagorean Theorem
<br><br>
<tt>(
a<sup>2</sup>
+ b<sup>2</sup>
= c<sup>2</sup>
)</tt>
<br><br>
<input
type=text
name=a
size=3><sup>2</sup>
+
<input
type=text
name=b
size=3><sup>2</sup>
=
<input
type=text
name=c
size=8>
<br><br>
<input
type=button
value="Solve"
onClick="solvepy(this.form)">
</form>
|
↓
|