How to make calculator in javascript
  • hello everyone please try this code for calculator program :)

    <FORM name="calculator">
    <TABLE border="4" align="center">
    <TR>
    <TD>
    <INPUT type="text"   name="Input" Size="27">
    <br>
    </TD>
    </TR>
    <TR>
    <TD>
    <INPUT type="button" name="one"   value="  1  " OnClick="calculator.Input.value += '1'">
    <INPUT type="button" name="two"   value="  2  " OnCLick="calculator.Input.value += '2'">
    <INPUT type="button" name="three" value="  3  " OnClick="calculator.Input.value += '3'">
    <INPUT type="button" name="plus"  value="  +  " OnClick="calculator.Input.value += ' + '">
    <br>
    <INPUT type="button" name="four"  value="  4  " OnClick="calculator.Input.value += '4'">
    <INPUT type="button" name="five"  value="  5  " OnCLick="calculator.Input.value += '5'">
    <INPUT type="button" name="six"   value="  6  " OnClick="calculator.Input.value += '6'">
    <INPUT type="button" name="minus" value="  -  " OnClick="calculator.Input.value += ' - '">
    <br>
    <INPUT type="button" name="seven" value="  7  " OnClick="calculator.Input.value += '7'">
    <INPUT type="button" name="eight" value="  8  " OnCLick="calculator.Input.value += '8'">
    <INPUT type="button" name="nine"  value="  9  " OnClick="calculator.Input.value += '9'">
    <INPUT type="button" name="times" value="  x  " OnClick="calculator.Input.value += ' * '">
    <br>
    <INPUT type="button" name="clear" value="  c  " OnClick="calculator.Input.value = ''">
    <INPUT type="button" name="zero"  value="  0  " OnClick="calculator.Input.value += '0'">
    <INPUT type="button" name="equal"  value="  =  " OnClick="calculator.Input.value = eval(calculator.Input.value)">
    <INPUT type="button" name="div"   value="  /  " OnClick="calculator.Input.value += ' / '">
    <br>
    </TD>
    </TR>
    </TABLE>
    </FORM>

    <p align="center"><font face="arial" size="2">Provided by</font><br>
    <font face="arial" size="2"><a href="http://www.codingresolved.com">www.codingresolved.com</a></font></p>

    After running this program the browser will display the page like this

    image

    Untitled-1.jpg
    239 x 211 - 29K
    hussainroyal
  • 4 Comments sorted by
  • hey hussain good ! its very intresting and also very useful your post always have depth of knowledge and detail keep it up.
  • thanks Waqas :)
    hussainroyal
  • very good, zabardast. i got it.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

Top Posters Weekly

Optimum Creative