Here is a simple scientific calculator HTML code that you can use for your website:
Codes of HTML:
<html> <head> <title>Scientific Calculator</title> </head> <body> <form> <input type="text" name="input" id="input" value=""> <br><br> <input type="button" value="sin" onclick="calculate('sin')"> <input type="button" value="cos" onclick="calculate('cos')"> <input type="button" value="tan" onclick="calculate('tan')"> <br><br> <input type="button" value="ln" onclick="calculate('ln')"> <input type="button" value="log" onclick="calculate('log')"> <input type="button" value="√" onclick="calculate('sqrt')"> <br><br> <input type="button" value="7" onclick="addToInput(7)"> <input type="button" value="8" onclick="addToInput(8)"> <input type="button" value="9" onclick="addToInput(9)"> <input type="button" value="/" onclick="addToInput('/')"> <br><br> <input type="button" value="4" onclick="addToInput(4)"> <input type="button" value="5" onclick="addToInput(5)"> <input type="button" value="6" onclick="addToInput(6)"> <input type="button" value="*" onclick="addToInput('*')"> <br><br> <input type="button" value="1" onclick="addToInput(1)"> <input type="button" value="2" onclick="addToInput(2)"> <input type="button" value="3" onclick="addToInput(3)"> <input type="button" value="-" onclick="addToInput('-')"> <br><br> <input type="button" value="0" onclick="addToInput(0)"> <input type="button" value="." onclick="addToInput('.')"> <input type="button" value="+" onclick="addToInput('+')"> <input type="button" value="=" onclick="calculate()"> </form> <script> function addToInput(val) { document.getElementById('input').value += val; } function calculate(val) { var input = document.getElementById('input').value; if (val) { input = val + '(' + input + ')'; } try { document.getElementById('input').value = eval(input); } catch (e) { document.getElementById('input').value = 'Error'; } } </script> </body> </html>
This calculator has buttons for the basic arithmetic operations (addition, subtraction, multiplication, and division), as well
PASTE THIS CODE ON YOUR WEBSITE HTML
0 Comments