Results 1 to 4 of 4

Thread: Create calculator with the use of JavaScript

  1. #1
    Join Date
    Jan 2009
    Posts
    65

    Create calculator with the use of JavaScript

    Hi, I am a student of BSC.I.T. and wanted to know how to create a calculator with the use of JavaScript. Can anyone give me code that can pasted and used as a calculator. Please if possible explain me. It can be simple or hard. Listen I don't know how to use javascript, this I want to learn just for my understanding.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Create calculator with the use of JavaScript

    Hi, I also don't know how to use java script but, I came across one of the source code on internet. I am giving you that code, you just try to R&D and then just look at it. It is simple.

    <html>
    <head>
    <FORM NAME="Calculator">
    <TABLE BORDER=4>
    <TR>
    <TD>
    <INPUT TYPE="text" NAME="Input" Size="16">
    <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="DOt" VALUE=" = " OnClick="Calculator.Input.value = eval(Calculator.Input.value)">
    <INPUT TYPE="button" NAME="Div" VALUE=" / " OnClick="Calculator.Input.value += ' / '">
    <br>
    </TD>
    </TR>
    </TABLE>
    </FORM>


    Just try it.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Create calculator with the use of JavaScript

    Hi, I am also trying to learn Javascript due to it's huge demand into the market. I will try this and then I will give you the source code directly. I am also completing my BSC.I.T. . As we are not having java script I decided to do it myself. Have you joint for any classes for this? I don't come across such coaching classes which provide you this course. Yes, you can join it by taking whole web design course. If you got this code before me just give it to me also by replying to this forum.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Post Re: Create calculator with the use of JavaScript

    Hi, I have done what you want. I am giving you whole steps and source of calculator application which you can use.

    CALCULATOR IN JAVASCRIPT:

    <BODY>

    <CENTER>
    <FORM NAME="Calc">

    <TABLE BORDER=4>
    <TR>
    <TD>
    <INPUT TYPE="text" NAME="Input" Size="16">
    <br>
    </TD>
    </TR>
    <TR>
    <TD>
    <INPUT TYPE="button" NAME="one" VALUE=" 1 " OnClick="Calc.Input.value += '1'">
    <INPUT TYPE="button" NAME="two" VALUE=" 2 " OnCLick="Calc.Input.value += '2'">
    <INPUT TYPE="button" NAME="three" VALUE=" 3 " OnClick="Calc.Input.value += '3'">
    <INPUT TYPE="button" NAME="plus" VALUE=" + " OnClick="Calc.Input.value += ' + '">
    <br>
    <INPUT TYPE="button" NAME="four" VALUE=" 4 " OnClick="Calc.Input.value += '4'">
    <INPUT TYPE="button" NAME="five" VALUE=" 5 " OnCLick="Calc.Input.value += '5'">
    <INPUT TYPE="button" NAME="six" VALUE=" 6 " OnClick="Calc.Input.value += '6'">
    <INPUT TYPE="button" NAME="minus" VALUE=" - " OnClick="Calc.Input.value += ' - '">
    <br>
    <INPUT TYPE="button" NAME="seven" VALUE=" 7 " OnClick="Calc.Input.value += '7'">
    <INPUT TYPE="button" NAME="eight" VALUE=" 8 " OnCLick="Calc.Input.value += '8'">
    <INPUT TYPE="button" NAME="nine" VALUE=" 9 " OnClick="Calc.Input.value += '9'">
    <INPUT TYPE="button" NAME="times" VALUE=" x " OnClick="Calc.Input.value += ' * '">
    <br>
    <INPUT TYPE="button" NAME="clear" VALUE=" c " OnClick="Calc.Input.value = ''">
    <INPUT TYPE="button" NAME="zero" VALUE=" 0 " OnClick="Calc.Input.value += '0'">
    <INPUT TYPE="button" NAME="DoIt" VALUE=" = " OnClick="Calc.Input.value = eval(Calc.Input.value)">
    <INPUT TYPE="button" NAME="div" VALUE=" / " OnClick="Calc.Input.value += ' / '">
    <br>
    </TD>
    </TR>
    </TABLE>
    </CENTER>
    <BODY>


    It will wok definitely.

Similar Threads

  1. How to use javascript to create HTML and CSS
    By KennedII in forum Software Development
    Replies: 5
    Last Post: 23-02-2010, 12:10 AM
  2. How to create shortcut for calculator in Windows Xp
    By Sunny55 in forum Customize Desktop
    Replies: 3
    Last Post: 30-06-2009, 01:47 PM
  3. Create Shortcut windows calculator
    By JonyL in forum Tips & Tweaks
    Replies: 1
    Last Post: 29-06-2009, 12:36 PM
  4. JavaScript - How to create Element
    By Xylina in forum Software Development
    Replies: 3
    Last Post: 04-06-2009, 05:06 PM
  5. Create php alert pop ups using javascript.
    By Suzane in forum Software Development
    Replies: 3
    Last Post: 13-04-2009, 03:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,540,791.29686 seconds with 17 queries