Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Html HTML Calculator

Related Tutorials


Share on Google+Share on Google+

HTML Calculator

In this example we will learn how to make HTML Calculator. We have used HTML language in this example.

HTML Calculator

In this example we will learn how to make HTML Calculator. We have used HTML language in this example. First off all we have created one table and we create 10 Button 0 to 9. We have created mathematical button "+, -, / ,and = "and we have created one clear screen button "C". This calculator can be used to perform simple mathematical operations like addition, subtraction, multiplication and division. A programmer can add, multiply, divide and subtract up to 9 digits. Clear screen button helps you to clear the screen. Text button is used to display the numbers. style is used fix the font size and Onclick is used for the button.


<form name="Calculator">
<table border="2" align="center" cellpadding="10" cellspacing="10" bgcolor="#00FFFF">
<input type="text" name="Input" Size="30">
<input type="button" name="one" style="font-size:25px" value=" 1 " OnClick="Calculator.Input.value += '1'">
<input type="button" name="two" style="font-size:25px" value=" 2 " OnCLick="Calculator.Input.value += '2'">
<input type="button" name="three" style="font-size:25px" value=" 3 " OnClick="Calculator.Input.value += '3'">
<input type="button" name="add" style="font-size:25px" value=" + " OnClick="Calculator.Input.value += ' + '">
<input type="button" name="four" style="font-size:25px" value=" 4 " OnClick="Calculator.Input.value += '4'">
<input type="button" name="five" style="font-size:25px" value=" 5 " OnCLick="Calculator.Input.value += '5'">
<input type="button" name="six" style="font-size:25px" value=" 6 " OnClick="Calculator.Input.value += '6'">
<input type="button" name="minus" style="font-size:25px" value=" - " OnClick="Calculator.Input.value += ' - '">
<input type="button" name="seven" style="font-size:25px" value=" 7 " OnClick="Calculator.Input.value += '7'">
<input type="button" name="eight" style="font-size:25px" value=" 8 " OnCLick="Calculator.Input.value += '8'">
<input type="button" name="nine" style="font-size:25px" value=" 9 " OnClick="Calculator.Input.value += '9'">
<input type="button" name="mul" style="font-size:25px" value=" * " OnClick="Calculator.Input.value += ' * '">
<input type="button" name="clear" style="font-size:25px" value=" c " OnClick="Calculator.Input.value = ''">
<input type="button" name="zero" style="font-size:25px" value=" 0 " OnClick="Calculator.Input.value += '0'">
<input type="button" name="DoIt" style="font-size:25px" value=" = " OnClick="Calculator.Input.value = eval(Calculator.Input.value)">
<input type="button" name="div" style="font-size:25px" value=" / " OnClick="Calculator.Input.value += ' / '">


Download Source Code


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 4, 2013

Related Tutorials

Discuss: HTML Calculator  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image