Calculates the arctangent of a number in JavaScript

Description

The following code shows how to calculates the arctangent of a number.

Example


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
  function doMath() {<!--from  w w  w . ja  v  a2  s .com-->
    var inputNum = document.form1.input.value;
    var result = Math.atan(inputNum);
    document.form1.answer.value = result;
  }
</script>
</head>
<body>
  <form name=form1>
    This example calculates the arctangent of the input number. <br>
    <br> Enter Number: <input type="text" name="input" size=10>
    <input type="button" value="Calculate" onClick='doMath()'> <br>
    The arctan is: <input type="text" name="answer" size=10>
  </form>
</body>
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window