A script that will find square roots of positive numbers. Not exciting,
but could be handy if you need a square root calculator for some reason.
Script Code
Grab a copy of the file below and place it in the same directory as the Web page on which
you will use the script (if you wish to place the script file in a different directory
you will need to make the necessary adjustments to the src attribute of the script tag
that calls it).
The code below should be placed between the <body> and </body> tags where
you want the calculator to appear.
Example
A working sample of the script is shown below.
Options
You can change the text for the input boxes and the submit button by editing the HTML code.
You can change the text of the error message by opening the scal1.js file
and editing the bold (strong) text on the following line of code:
window.alert("Please enter a positive number to get a square root.");
If you need to use single or double quotation marks within the error message text,
you should write them with a backslash before them (i.e. \" and \')
in order to avoid JavaScript errors.
Accessibility
A server-side script that calculates square roots could be used for those without
JavaScript by directing the form tag's action
attribute to the server-side script.