<!-- CIRCLE AREA FINDER --> <!-- This goes in the HEAD of the html file --> <script language="JavaScript" type="text/javascript"> <!-- Copyright 2002, Sandeep Gangadharan --> <!-- For more free scripts go to http://sivamdesign.com/scripts/ --> <!-- function circleArea() { var c1 = document.carea.circle.value; if (document.carea.cchoice.selectedIndex == 1) { document.carea.result.value = Math.round(Math.PI * ((c1) / 2) * ((c1) / 2) * 10000) / 10000; } dia1 = c1 / Math.PI; if (document.carea.cchoice.selectedIndex == 2) { document.carea.result.value = Math.round(Math.PI * ((dia1) / 2) * ((dia1) / 2) * 10000) / 10000; } dia2 = c1 * 2; if (document.carea.cchoice.selectedIndex == 3) { document.carea.result.value = Math.round(Math.PI * ((dia2) / 2) * ((dia2) / 2) * 10000) / 10000; } if (document.carea.cchoice.selectedIndex == 0) { alert('You have to now choose the type of input\nwhether diameter, circumference or radius.') } if (c1 == "") { alert('Input not complete!'); } if (document.carea.result.value == "NaN") { alert('Input not correct!'); } } //--> </script> <!-- This goes in the BODY of the html file --> <form name="carea"> <table border="0" cellpadding="4" cellspacing="0" bgcolor="#cccccc"> <tr> <td><font face="verdana, arial, helvetica, sans-serif" size="1"> Input: <input type="text" size="4" name="circle" style="font-size: 9pt" /> <select name="cchoice" style="font-size: 9pt"> <option value="0" selected>Choose...</option> <option value="1">Diameter</option> <option value="2">Circumference</option> <option value="3">Radius</option> </select>&nbsp;</font> </td> <td align="center" rowspan="3" width="90"> <input type="button" value="Get Area" name="it" onClick="circleArea()" style="font-size: 9pt" /><br /> <input type="reset" value="Reset" onClick="reset()" style="font-size: 9pt" /> </td> <td rowspan="3"> <input type="text" name="result" size="8" /> </td> </tr> </table> </form>