A simple program that I wrote that will compute the square root of a number in JavaScript. The code is very simple and easy to understand.
My mobile number here in the Philippines is 09173084360.
If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
<html>
<title> Square Root Calculator in JavaScript</title>
<body>
<center>
<script>
function calcsqrt(form)
{
var number=form.number.value;
var ans=Math.sqrt(number);
if (number<0) ans="Invalid";
form.sqrt.value=ans;
}
</script>
<table width="40%" border="8" cellpadding="5" cellspacing="15" bgcolor="lightgreen">
<tr>
<td align="center" ><h3> <font face="comic sans ms" color="blue" >Square Root Calculator </font></h3>
<form action="#" method="get" name="form">
<font size="4" face="comic sans ms" color="blue">√</font><input name="number" type="text" class="regfont" size="6"/>
<br /><br /><input type="button" onclick="calcsqrt(this.form)" value="Find the Square Root"/>
<br /><br /><font face="comic sans ms" color="blue">
The Square Root Value is:<input name="sqrt" type="text" class="regfont" size="20"/><br /><br />
</form>
</td>
</tr>
</table>
</center>
</body>
</html>
No comments:
Post a Comment