Easy and Simple Calculator

11 posts Page 1 of 2
Contributors
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Easy and Simple Calculator
mikethedj4
Well here's a very, easy and simple calculator for you guys, of course you can tinker with the code however you want, and style it.
Code: Select all
<!-- Calculator -->
<form name="Calc" action="">
<div class="colorscheme2">
<input type="text" name="Input" size="16" />
</div>
<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=" * " 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="comp"  value=" = " 
onclick="Calc.Input.value = eval(Calc.Input.value)" />
<input type="button" name="div"   value=" / " onclick="Calc.Input.value += ' / '" />
</form>
<!-- end Calculator -->
Just copy the text above and paste it into a text editor, and save it as filename.html, and you can begin tinkering with the code doing whatever you want, and when you move the .html file you created into a web browser you'll be able to see that calculator you just got.

Here's a stylized version I created of the exact same calculator below.
calculator.png
If you wanna use the styled version feel free :)
calculator.zip
Edit:
Here's a post I made on how to do this in JQuery - http://codenstuff.com/forum/viewtopic.php?f=245&t=10964
You do not have the required permissions to view the files attached to this post.
Last edited by mikethedj4 on Fri Sep 13, 2013 7:32 am, edited 4 times in total.
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: Easy and Simple Calculator
Usman55
First of all, congratz on 1000 posts. Second, nice tut, in which software can I make this?
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Easy and Simple Calculator
mandai
Use a text editor to save the htm file.
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: Easy and Simple Calculator
Usman55
Okay mandai, I'll try that. Isn't it visual?
Image
User avatar
Skillful
Skillful Coders
Skillful Coders
Posts: 969
Joined: Tue Nov 16, 2010 10:07 am

Re: Easy and Simple Calculator
Skillful
Nice work mikethedj! Keep it up. Also, congrats for completing 1000 posts!
Instead of LOL use this -
LSIBMHBIWFETALOL

Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
User avatar
Zulf
Serious Programmer
Serious Programmer
Posts: 441
Joined: Fri Jun 11, 2010 7:46 am

Re: Easy and Simple Calculator
Zulf
Usman55 wrote:
Okay mandai, I'll try that. Isn't it visual?
No, Mike and some other members here are good at HTML.
Image
Vikhedgehog
VIP - Donator
VIP - Donator
Posts: 812
Joined: Fri Nov 05, 2010 6:24 pm

Re: Easy and Simple Calculator
Vikhedgehog
If You Save It As *.hta it'll Work As An App.
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: Easy and Simple Calculator
Usman55
Vikhedgehog wrote:
If You Save It As *.hta it'll Work As An App.
Yeah, it worked. Thanks for the tip... And basically what the app does is that it makes the textbox to answer the question either it is addition, subtraction, multiplication or division. Anyways, I like it.
Image
User avatar
mikethedj4
VIP - Site Partner
VIP - Site Partner
Posts: 2592
Joined: Thu Mar 25, 2010 4:36 am

Re: Easy and Simple Calculator
mikethedj4
Thanks for the congrats on 1000 posts, I didn't even notice.

and no this is not visual, this is HTML, and JavaScript.

I used JS to script it for the match, and html to markup everything.

BTW: HTML stands for "HyperText Markup Language".
GoodGuy17
Coding God
Coding God
Posts: 1610
Joined: Mon Sep 07, 2009 12:25 am

Re: Easy and Simple Calculator
GoodGuy17
I thought I saw this somewhere else, but I guess I didn't.
Nice job, Mike. This seems useful, but I don't really make too many sites. Also, is there any way to change the background of the calculator?
11 posts Page 1 of 2
Return to “Tutorials”