Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

back to Forms and Scripts

Source Code for Geometric Properties Form

This code creates the geometric properties form:

<SCRIPT TYPE="text/javascript">
<!--
function Circle_calc(GeoForm)
{
var CircleRadius = GeoForm.Circle_radius.value;
if (CircleRadius >= 0)
   {
   GeoForm.Circle_circumference.value =  2 * Math.PI * CircleRadius ;
   GeoForm.Circle_area.value =  Math.PI * Math.pow(CircleRadius, 2) ;
   }
else
   {
   GeoForm.Circle_circumference.value =  "";
   GeoForm.Circle_area.value =  "";
   }
}

function Cone_calc(GeoForm)
{
var ConeRadius = GeoForm.Cone_radius.value;
var ConeHeight = GeoForm.Cone_height.value;

if ((ConeRadius >= 0) && (ConeHeight >= 0))
   {
   GeoForm.Cone_surfacearea.value = (Math.PI * Math.pow(ConeRadius, 2)) + (Math.PI * ConeRadius * Math.sqrt(Math.pow(ConeRadius, 2) + Math.pow(ConeHeight, 2)));
   GeoForm.Cone_volume.value = (1/3) * Math.PI * Math.pow(ConeRadius,2) * ConeHeight;
   }
else
   {
   GeoForm.Cone_surfacearea.value = "";
   GeoForm.Cone_volume.value = "";
   }
}

function Sphere_calc(GeoForm)
{
var SphereRadius = GeoForm.Sphere_radius.value;

if (SphereRadius >= 0) 
   {
   GeoForm.Sphere_surfacearea.value = 4 * Math.PI * Math.pow(SphereRadius, 2);
   GeoForm.Sphere_volume.value = (4/3) * Math.PI * Math.pow(SphereRadius, 3);
   }
else
   {
   GeoForm.Sphere_surfacearea.value = "";
   GeoForm.Sphere_volume.value = "";
   }
}
// -->
</SCRIPT>

<FORM>
<TABLE BORDER CELLPADDING=3>
<!-- circumference and radius of a circle -->
<TR>

<TH>Circumference and Radius of a Circle<BR><IMG SRC="../graphics/circle.gif" HEIGHT=88 WIDTH=88 ALT="picture of a circle"></TH>
<TD><NOBR>radius: <INPUT NAME="Circle_radius" SIZE=4></NOBR></TD>
<TD><INPUT TYPE=BUTTON OnClick="Circle_calc(this.form);" VALUE="calculate"></TD>
<TD ALIGN=RIGHT BGCOLOR="#AACCFF">
   <NOBR>circumference: <INPUT NAME="Circle_circumference" SIZE=9></NOBR><BR>
   <NOBR>area: <INPUT NAME="Circle_area" SIZE=9></NOBR></TD>
</TR>

<!-- Surface area and volume of a cone -->
<TR>
<TH>Surface Area and Volume of a Cone<BR><IMG SRC="../graphics/cone.gif" HEIGHT=106 WIDTH=115 ALT="picture of a cone"></TH>
<TD ALIGN=RIGHT><NOBR>radius: <INPUT NAME="Cone_radius" SIZE=4></NOBR><BR>
   <NOBR>height: <INPUT NAME="Cone_height" SIZE=4></NOBR></TD>
<TD><INPUT TYPE=BUTTON OnClick="Cone_calc(this.form);" VALUE="calculate"></TD>
<TD ALIGN=RIGHT BGCOLOR="#AACCFF">
   <NOBR>surface area: <INPUT NAME="Cone_surfacearea" SIZE=9></NOBR><BR>
   <NOBR>volume: <INPUT NAME="Cone_volume" SIZE=9></NOBR></TD>
</TR>

<!-- Surface Area and Volume of a Sphere -->
<TR>
<TH>Surface Area and Volume of a Sphere<BR><IMG SRC="../graphics/sphere.gif" HEIGHT=88 WIDTH=88 ALT="picture of a sphere"></TH>
<TD><NOBR>radius: <INPUT NAME="Sphere_radius" SIZE=4></NOBR></TD>
<TD><INPUT TYPE=BUTTON OnClick="Sphere_calc(this.form);" VALUE="calculate"></TD>
<TD ALIGN=RIGHT BGCOLOR="#AACCFF"><NOBR>surface area: <INPUT NAME="Sphere_surfacearea" SIZE=9></NOBR><BR>
   <NOBR>volume: <INPUT NAME="Sphere_volume" SIZE=9></NOBR></TD>
            
</TR>
</TABLE>
</FORM>

which gives us this form:

Circumference and Radius of a Circle
picture of a circle
radius: circumference:
area:
Surface Area and Volume of a Cone
picture of a cone
radius:
height:
surface area:
volume:
Surface Area and Volume of a Sphere
picture of a sphere
radius: surface area:
volume:

 
 
  Copyright 1997-2002 Idocs inc. Published under the terms of the Open Content License Design by Interspire