How to Create Calculator in JavaScript

JavaScript is vast programming language through which you can create any web application. JavaScript use in every single element on web application. Means that use of java script in web programming is necessary. Using JavaScript you make online calculator, online currency converter or anything which you want you can build in JavaScript which works online and offline on your web page. As you know calculator is a basic necessary element in our life. For example if you want to find the percentage of your income then you'll need to use calculator for calculation.
In this tutorial i am gonna show you that how to create calculator in JavaScript. You can also stylize this calculator source code by using CSS style sheet according to your requirements.

Calculator in JavaScript

how to create calculator in javascript

Calculator JavaScript Code

<h2>Calculator in Javascript</h2>
<form Name="calculator">
<table border=2>
<td colspan=4><input type=text Name="disp"></td>
<td><input type=button value="0" OnClick="calculator.disp.value+='0'"></td>
<td><input type=button value="1" OnClick="calculator.disp.value+='1'"></td>
<td><input type=button value="2" OnClick="calculator.disp.value+='2'"></td>
<td><input type=button value="+" OnClick="calculator.disp.value+='+'"></td>
<td><input type=button value="3" OnClick="calculator.disp.value+='3'"></td>
<td><input type=button value="4" OnClick="calculator.disp.value+='4'"></td>
<td><input type=button value="5" OnClick="calculator.disp.value+='5'"></td>
<td><input type=button value="-" OnClick="calculator.disp.value+='-'"></td>
<td><input type=button value="6" OnClick="calculator.disp.value+='6'"></td>
<td><input type=button value="7" OnClick="calculator.disp.value+='7'"></td>
<td><input type=button value="8" OnClick="calculator.disp.value+='8'"></td>
<td><input type=button value="x" OnClick="calculator.disp.value+='*'"></td>
<td><input type=button value="9" OnClick="calculator.disp.value+='9'"></td>
<td><input type=button value="C" OnClick="calculator.disp.value=''"></td>
<td><input type=button value="=" OnClick="calculator.disp.value=eval(calculator.disp.value)"></td>
<td><input type=button value="/" OnClick="calculator.disp.value+='/'"></td>