August 1999
Intermediate to advanced
1488 pages
72h 53m
English
math.sqrt(num)
The sqrt() method of the Math object is used to calculate the square root of a number. If the return value is outside the required range, sqrt() returns 0.
Listing 6.173 shows how the sqrt() method is used.
<html> <body> <script language="JavaScript"> <!–– Hide // function calculates the square root of input number function doMath(){ var inputNum1=document.form1.input1.value; var result = Math.sqrt(inputNum1); document.form1.answer.value = result; } // End Hide ––> </script> <form name=form1> Enter Number: <input type="text" name="input1" size=10> <input type="button" ... |
Read now
Unlock full access