<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin function addChar(input, character) { if(input.value == null || input.value == "0") input.value = character else input.value += character } function cos(form) { form.display.value = Math.cos(form.display.value);} function sin(form) { form.display.value = Math.sin(form.display.value);} function tan(form) { form.display.value = Math.tan(form.display.value);} function sqrt(form) { form.display.value = Math.sqrt(form.display.value);} function ln(form) { form.display.value = Math.log(form.display.value);} function exp(form) { form.display.value = Math.exp(form.display.value);} function sqrt(form) { form.display.value = Math.sqrt(form.display.value);} function deleteChar(input) { input.value = input.value.substring(0, input.value.length - 1) } function changeSign(input) { if(input.value.substring(0, 1) == "-") input.value = input.value.substring(1, input.value.length) else input.value = "-" + input.value } function compute(form) { form.display.value = eval(form.display.value)} function square(form) { form.display.value = eval(form.display.value) * eval(form.display.value)} function checkNum(str) { for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i+1) if (ch < "0" || ch > "9") { if (ch != "/" && ch != "*" && ch != "+" && ch != "-" && ch != "." && ch != "(" && ch!= ")") { alert("invalid entry!") return false } } } return true } // End --> </SCRIPT> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> </head>
<body> <table width="100%" border="1"> <tr> <td><div align="center"> <!-- TWO STEPS TO INSTALL YOUR SCIENTIFIC CALCULATOR:
1. Paste the designated coding into the HEAD of your HTML document 2. Put the last script into the BODY of your HTML document --> <!-- STEP ONE: Copy this code into the HEAD of your HTML document --> <CENTER> <FORM> <table width="50%" border="1"> <tr> <td colspan="5"><div align="center"></div> <div align="center"> <input name="display" value="0" size=40> </div></td> </tr> <tr> <td><div align="center"> <input name="button" type="button" onClick="if (checkNum(this.form.display.value)) { exp(this.form) }" value=" exp "> </div></td> <td><div align="center"> <input name="button2" type="button" onClick="addChar(this.form.display, '7')" value=" 7 "> </div></td> <td><div align="center"> <input name="button3" type="button" onClick="addChar(this.form.display, '8')" value=" 8 "> </div></td> <td><div align="center"> <input name="button4" type="button" onClick="addChar(this.form.display, '9')" value=" 9 "> </div></td> <td><div align="center"> <input name="button5" type="button" onClick="addChar(this.form.display, '/')" value=" / "> </div></td> </tr> <tr> <td><div align="center"> <input name="button6" type="button" onClick="if (checkNum(this.form.display.value)) { ln(this.form) }" value=" ln "> </div></td> <td><div align="center"> <input name="button7" type="button" onClick="addChar(this.form.display, '4')" value=" 4 "> </div></td> <td><div align="center"> <input name="button8" type="button" onClick="addChar(this.form.display, '5')" value=" 5 "> </div></td> <td><div align="center"> <input name="button9" type="button" onClick="addChar(this.form.display, '6')" value=" 6 "> </div></td> <td><div align="center"> <input name="button10" type="button" onClick="addChar(this.form.display, '*')" value=" * "> </div></td> </tr> <tr> <td><div align="center"> <input name="button11" type="button" onClick="if (checkNum(this.form.display.value)) { sqrt(this.form) }" value=" sqrt "> </div></td> <td><div align="center"> <input name="button12" type="button" onClick="addChar(this.form.display, '1')" value=" 1 "> </div></td> <td><div align="center"> <input name="button13" type="button" onClick="addChar(this.form.display, '2')" value=" 2 "> </div></td> <td><div align="center"> <input name="button14" type="button" onClick="addChar(this.form.display, '3')" value=" 3 "> </div></td> <td><div align="center"> <input name="button15" type="button" onClick="addChar(this.form.display, '-')" value=" - "> </div></td> </tr> <tr> <td><div align="center"> <input name="button16" type="button" onClick="if (checkNum(this.form.display.value)) { square(this.form) }" value=" sq "> </div></td> <td><div align="center"> <input name="button17" type="button" onClick="addChar(this.form.display, '0')" value=" 0 "> </div></td> <td><div align="center"> <input name="button18" type="button" onClick="addChar(this.form.display, '.')" value=" . "> </div></td> <td><div align="center"> <input name="button19" type="button" onClick="changeSign(this.form.display)" value=" +/- "> </div></td> <td><div align="center"> <input name="button20" type="button" onClick="addChar(this.form.display, '+')" value=" + "> </div></td> </tr> <tr> <td><div align="center"> <input name="button21" type="button" onClick="addChar(this.form.display, '(')" value=" ( "> </div></td> <td><div align="center"> <input name="button22" type="button" onClick="if (checkNum(this.form.display.value)) { cos(this.form) }" value=" cos "> </div></td> <td><div align="center"> <input name="button23" type="button" onClick="if (checkNum(this.form.display.value)) { sin(this.form) }" value=" sin "> </div></td> <td><div align="center"> <input name="button24" type="button" onClick="if (checkNum(this.form.display.value)) { tan(this.form) }" value=" tan "> </div></td> <td><div align="center"> <input name="button25" type="button" onClick="addChar(this.form.display, ')')" value=" ) "> </div></td> </tr> <tr> <td><div align="center"></div></td> <td><div align="center"> <input name="button26" type="button" onClick="this.form.display.value = 0 " value=" Clear "> </div></td> <td><div align="center"> <input name="button27" type="button" onClick="deleteChar(this.form.display)" value=" Back Space "> </div></td> <td><div align="center"> <input type="button" value=" Enter " name="enter" onClick="if (checkNum(this.form.display.value)) { compute(this.form) }"> </div></td> <td><div align="center"></div></td> </tr> </table> <br> <br> <br> <br> <br> <br> </FORM> |