Calculate the natural logarithm (base E) of a number in JavaScript
Description
The following code shows how to calculate the natural logarithm (base E) of a number.
Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function doMath() {<!-- w w w . ja v a2 s . c om-->
var inputNum = document.form1.input.value;
var result = Math.log(inputNum);
document.form1.answer.value = result;
}
</script>
</head>
<body>
<form name=form1>
This example calculates the natural log of the number entered. <br>
<br> Enter First Number: <input type="text" name="input" size=15>
<input type="button" value="Calculate" onClick='doMath()'> <br>
The log is: <input type="text" name="answer" size=10>
</form>
</body>
</html>