Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 14-11-2009
Member
 
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.
Reply With Quote
  #2  
Old 14-11-2009
Member
 
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.
Reply With Quote
  #3  
Old 14-11-2009
Member
 
Join Date: May 2008
Posts: 2,008
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.
Reply With Quote
  #4  
Old 14-11-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 03:48 AM.