Sample JavaScript Programs

by Tom

Sample #1:
To Computer the Square Root of a Number:
     Notes:

<html>
<head>
<title>Sample: Tom's Square Root Program</title>

<
script language="JavaScript">
function TomsSqrtPgm(form) {
form.TomsSqrtResult.value = Math.sqrt(form.TomsNumIn.value); }
</script>
</head>

<body>
<h2>Tom's SQRT Calculator</h2>

<form name="TomsSqrtCalc">
<p>Enter a Number: <
input type="text" name="TomsNumIn" value size="7">
<input
type="button" value="Click for Ans:" onClick="TomsSqrtPgm(document.TomsSqrtCalc">
<
input type="text" name="TomsSqrtResult" value size="7"> </p>
</form>

</body>
</html>

Try It !