Script Categories













Calculators >>> Square Root.

Allows you to find the value of a number squared or that number's square root.



Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function sqRt(form) {
var number = form.num.value;
var ans = Math.sqrt(number);
form.answer.value = ans;
}
function sqIt(form) {
var number = form.num.value;
var ans = eval(number * number);
form.answer.value = ans;
}
//  End -->
</script>
<form>
<table border=1>
<tr>
<td>
<input type=text name=num size=10>
</td>
<td>
<input type=button value="Sq. Root" onClick="sqRt(this.form)"><br>
<input type=button value="Square It" onClick="sqIt(this.form)">
</td>
<td>
<input type=text name=answer size=15><br>
<input type=button value="<-- copy back" onClick="this.form.num.value = this.form.answer.value">
</td>
</tr>
</table>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

R7


©