<!-- TRIGONOMETRIC FUNCTIONS --> <!-- 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 trig() { var X = document.trigo.val.value; if (document.trigo.chTrig.selectedIndex == 0) { document.trigo.result.value = ""; } if (document.trigo.chTrig.selectedIndex == 1) { document.trigo.result.value = Math.round(Math.sin(X) * 10000) / 10000; if (document.trigo.arc.checked) { document.trigo.result.value = Math.round(Math.asin(X) * 10000) / 10000; } if (document.trigo.degree.checked) { document.trigo.result.value = Math.round((Math.sin(X * 3.1415/180)) * 10000) / 10000; } if (document.trigo.gradient.checked) { document.trigo.result.value = Math.round((Math.sin(X * 3.1415/100/2)) * 10000) / 10000; } } if (document.trigo.chTrig.selectedIndex == 2) { document.trigo.result.value = Math.round(Math.cos(X) * 10000) / 10000; if (document.trigo.arc.checked) { document.trigo.result.value = Math.round(Math.acos(X) * 10000) / 10000; } if (document.trigo.degree.checked) { document.trigo.result.value = Math.round((Math.cos(X * 3.1415/180)) * 10000) / 10000; } if (document.trigo.gradient.checked) { document.trigo.result.value = Math.round((Math.cos(X * 3.1415/100/2)) * 10000) / 10000; } } if (document.trigo.chTrig.selectedIndex == 3) { document.trigo.result.value = Math.round(Math.tan(X) * 10000) / 10000; if (document.trigo.arc.checked) { document.trigo.result.value = Math.round(Math.atan(X) * 10000) / 10000; } if (document.trigo.degree.checked) { document.trigo.result.value = Math.round((Math.tan(X * 3.1415/180)) * 10000) / 10000; } if (document.trigo.gradient.checked) { document.trigo.result.value = Math.round((Math.tan(X * 3.1415/100/2)) * 10000) / 10000; } } if (document.trigo.result.value == "NaN") { alert("Invalid input for function!"); return false; } } function checkIt1() { if (document.trigo.arc.checked == true) { (document.trigo.degree.checked = false) || (document.trigo.gradient.checked = false) } } function checkIt2() { if (document.trigo.degree.checked == true) { (document.trigo.arc.checked = false) || (document.trigo.gradient.checked = false) } } function checkIt3() { if (document.trigo.gradient.checked == true) { (document.trigo.degree.checked = false) || (document.trigo.arc.checked = false) } } //--> </script> <body> <form name="trigo"> <table border="0" cellpadding="4" cellspacing="0" bgcolor="#cccccc"> <tr> <td bgcolor="#000080" colspan="7"><font face="ms sans serif, arial, helvetica, sans-serif" size="1" color="#ffffff"><b>Trigonometric Functions</b></font></td> </tr> <tr> <td><font face="verdana, arial, helvetica, sans-serif" size="1"><b>Angle</b></font></td> <td><font face="verdana, arial, helvetica, sans-serif" size="1"><b>Function</b></font></td> <td><font face="verdana, arial, helvetica, sans-serif" size="1"><b>Inverse</b></font></td> <td><font face="verdana, arial, helvetica, sans-serif" size="1"><b>Degrees</b></font></td> <td><font face="verdana, arial, helvetica, sans-serif" size="1"><b>Gradients</b></font></td> <td align="center"><input type="reset" value="Reset" style="font-size: 9pt" /></td> <td><font face="verdana, arial, helvetica, sans-serif" size="1">&nbsp;&nbsp;<b>Value</b></font></td> </tr> <tr> <td><input type="text" name="val" size="10" style="font-size: 9pt" /></td> <td> <select name="chTrig" style="font-size: 9pt"> <option value="0" selected>Choose...</option> <option value="1">Sin</option> <option value="2">Cos</option> <option value="3">Tan</option> </select> </td> <td><input type="checkbox" name="arc" onClick="checkIt1()" /></td> <td><input type="checkbox" name="degree" onClick="checkIt2()" /></td> <td><input type="checkbox" name="gradient" onClick="checkIt3()" /></td> <td><input type="button" value="Compute" style="font-size: 9pt" onClick="trig()" /></td> <td>&nbsp;<input type="text" name="result" size="10" style="font-size: 9pt" /></td> </tr> </table> </form>