JavaScript Source Code 3000: Calculators: Area Calculator
Area Calculator
A simple calculator to determine the area of a square, triangle, rectangle, circle or sphere.
Find the area of a
...
Square
Triangle
Rectangle
Circle
Sphere
=
JavaScript Source Code 3000: Calculators: Area Calculator
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!
<!-- TWO STEPS TO INSTALL AREA CALCULATOR:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Michael Hundt (mchundt@nglic.com) -->
<!-- Web Site: http://www.cinet.net/~mhundt/mystuff.htm -->
<!-- Modified by: Ronnie T. Moore (JavaScript Source) -->
<! >
<! >
<!-- Begin
function doArea(num) {
switch(num) {
case 0 : return (""); break;
case 1 : var length = prompt("Please enter the length of your square:", "");
length = length * length;
return (length); break;
case 2 : var width = prompt("Please enter the width of the base:", "");
var height = prompt("Please enter the height of the triangle:", "");
return (width * height / 2); break;
case 3 : var width = prompt("Please enter the width of your rectangle:", "");
var height = prompt("Please enter the height of your rectangle:", "");
return (width * height); break;
case 4 : var radius = prompt("Please enter the radius of the circle: ", "");
return (Math.PI * Math.pow(radius, 2)); break;
case 5 : var radius = prompt("Please enter the radious of the sphere:", 0);
return (4 * Math.PI * (Math.pow(radius, 2))); break;
}
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<center>
<form name=calcarea>
Find the area of a
<select name="shape" size="1" onChange="this.form.area.value = doArea(this.selectedIndex);">
<option> ...
<option value="square">Square
<option value="triangle">Triangle
<option value="rectangle">Rectangle
<option value="circle">Circle
<option value="sphere">Sphere
</select>
= <input type=text name=area size=10>
</form>
</center>
<!-- Script Size: 2.01 KB -->
Wyszukiwarka
Podobne podstrony:
avoid areaavoid areamatrix calcNicks Hardware Areaavoid arealang rouss 1 montpellier area v1 m56577569830523116MEPC 154(55) Designation of the Southern South African waters as a Special Areastar calc WHATSNEWcalc?fectavoid areaavoid areaArealang rouss 1 toulouse area v1 m56577569830523119avoid areaareaWinchester city area mapwięcej podobnych podstron