How to create Calculator by using Javascript

How to create Calculator by using JavaScript. It is so simple only you must have to know the little bit of DOM( Document Object Modal).

<html> <title>Agyanadda cal</title> <style>input[type="button"]{width:100%}</style> <head> <body> <form name="cal"> <table border="1" align="center"> <tr> <td colspan="4"> <input type="text" name="display" id="display" disabled> </td> </tr> <tr> <td><input type="button" name="one" value="1" onclick="cal.display.value += '1'"></td> <td><input type="button" name="two" value="2" onclick="cal.display.value += '2'"></td> <td><input type="button" name="three" value="3" onclick="cal.display.value += '3'"></td> <td><input type="button" class="o perator" name="plus" value="+" onclick="cal.display.value += '+'"></td> </tr> <tr> <td><input type="button" name="four" value="4" onclick="cal.display.value += '4'"></td> <td><input type="button" name="five" value="5" onclick="cal.display.value += '5'"></td> <td><input type="button" name="six" value="6" onclick="cal.display.value += '6'"></td> <td><input type="button" class="operator" name="minus" value="-" onclick="cal.display.value += '-'"></td> </tr> <tr> <td><input type="button" name="seven" value="7" onclick="cal.display.value += '7'"></td> <td><input type="button" name="eight" value="8" onclick="cal.display.value += '8'"></td> <td><input type="button" name="nine" value="9" onclick="cal.display.value += '9'"></td> <td><input type="button" class="operator" name="times" value="x" onclick="cal.display.value += '*'"></td> </tr> <tr> <td><input type="button" id="clear" name="clear" value="c" onclick="cal.display.value = ''"></td> <td><input type="button" name="zero" value="0" onclick="cal.display.value += '0'"></td> <td><input type="button" name="doit" value="=" onclick="cal.display.value = eval(cal.display.value)"></td> <td><input type="button" class="operator" name="div" value="/" onclick="cal.display.value += '/'"></td> </tr> </table> </form> </body> </head> </html>

agyanadda

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 $type={blogger}:

Post a Comment