Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,340 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,098 people online right now. Registration is fast and FREE... Join Now!




simple calculator

 
Reply to this topicStart new topic

simple calculator, java script

planet
post 28 Sep, 2008 - 04:44 AM
Post #1


New D.I.C Head

*
Joined: 28 Sep, 2008
Posts: 2

hii i need help.. i dont know how to start on writing a simple calculator code.. it doesnt have to have a picture.. i just would need to give to show the outcome of the input
eg.
input: 100+9
output 100+9 = 109
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 28 Sep, 2008 - 07:30 AM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,983



Thanked 78 times

Dream Kudos: 1175
My Contributions


One thing that could really help out people that may be willing to help if knowing what language you are looking at attempting this in, that way they will know if they should even reply or not and you may get some more replies faster.
User is offlineProfile CardPM

Go to the top of the page

planet
post 28 Sep, 2008 - 07:35 AM
Post #3


New D.I.C Head

*
Joined: 28 Sep, 2008
Posts: 2

QUOTE(BetaWar @ 28 Sep, 2008 - 08:30 AM) *

One thing that could really help out people that may be willing to help if knowing what language you are looking at attempting this in, that way they will know if they should even reply or not and you may get some more replies faster.



hi sorry to add. i nid help in java script.. it doesnt have to be applet.. just normal script..
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 28 Sep, 2008 - 07:56 AM
Post #4


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,983



Thanked 78 times

Dream Kudos: 1175
My Contributions


After a quick google search:

CODE
<script language="javascript">
var inputstring=" "
function updatestring(value)
{
    inputstring += value;
    document.calculator.input.value=inputstring;
}
</script>

<body bgcolor="red" topmargin="80">
<center>
<table border=5 bordercolor=pink  cellspacing=8>
<form name="calculator">
<th>
THE CALCULATOR
</th>
<tr align="center">
<td>
<input type="text" name="input" maxlength=10 size=24>
</td></tr>
<tr align="center"><td>
    <input type="button" value="  +  " onclick="updatestring('+')">
    <input type="button" value="  -  " onclick="updatestring('-')">
    <input type="button" value="  /  " onclick="updatestring('/')">
    <input type="button" value="  *  " onclick="updatestring('*')">
</td></tr><tr align=center><td>
        <input type="button" value="  mod  " onclick="updatestring('%')">
        <input type="button" value="  0  " onclick="updatestring('0')">
        <input type="button" value="  1  " onclick="updatestring('1')">
        <input type="button" value="  2  " onclick="updatestring('2')">
</td</tr><tr align=center><td>
            <input type="button" value="  3  " onclick="updatestring('3')">
            <input type="button" value="  4  " onclick="updatestring('4')">
            <input type="button" value="  5  " onclick="updatestring('5')">
            <input type="button" value="  6  " onclick="updatestring('6')">
</td></tr><tr align="center"><td>
                <input type="button" value="  7  " onclick="updatestring('7')">
                <input type="button" value="  8  " onclick="updatestring('8')">
                <input type="button" value="  9  " onclick="updatestring('9')">
</td></tr>
<tr align="center"><td>
                    <input type="button" value="  clear  " onclick="input.value=' ';inputstring=' ' ">
                        <input type="button" value="  =  " onclick="input.value=eval(inputstring);">
</td>
</tr>
</form>
</table>


Hope that helps.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 03:36AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month