August 1999
Intermediate to advanced
1488 pages
72h 53m
English
math.PIThe PI property of the Math object is used to get the constant PI. This is approximately 3.14159.
Listing 6.168 shows how the PI property is used. When the user clicks the Calculate button, the doMath function is called, which calculates the value of PI and returns the result to the text box.
<html> <body> <script language="JavaScript"> <!–– Hide // function returns the value of PI function doMath(){ var result = Math.PI; document.form1.answer.value = result; } // End Hide ––> </script> <form name=form1> The Approximate value of PI is: <input type="text" name="answer" size=20> ... |
Read now
Unlock full access