Online Calculator JS source code

Source: Internet
Author: User
Tags clear screen


<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Super Cool JS Web calculator code-JS code NET </title>
<style>
body,div,p,ul,li,input{margin:0;padding:0;}
Ul{list-style-type:none;}
A{color: #fff; outline:none;text-decoration:none;}
body{font:700 24px/1.5 Arial;}
#calc {position:relative;width:300px;background: #000; margin:10px auto;}
#calc p{color: #fff; text-align:right;font:12px/20px arial;padding:0 5px;background: #fff}
#calc. f-text{border:0;width:290px;height:84px;text-align:right;font:700 50px/84px Arial;background:url (img/ inputbg.jpg) repeat-x;padding:0 5px;}
#calc Ul{position:relative;overflow:hidden;zoom:1;background:url (img/bg.jpg);p adding:0 0 17px 8px;}
#calc ul li{float:left;width:63px;height:41px;margin:17px 10px 0 0;}
#calc ul Li A{display:block;width:63px;height:41px;line-height:41px;text-align:center;background:url (img/btn.png) No-repeat;}
#calc ul li a:hover{background-position:-63px 0;}
#calc ul li.btn-1 a{background-position:0 -41px;}
#calc ul li.btn-1 a:hover{background-position:-63px-41px;}
#calc ul li.btn-2{position:absolute;top:174px;right:0;height:99px;}
#calc ul li.btn-2 a{height:99px;line-height:99px;background-position:0 -164px;}
#calc ul li.btn-2 a:hover{background-position:-63px-164px;}
#calc ul li.btn-3{width:136px;}
#calc ul li.btn-3 a{width:136px;background-position:0 -82px;}
#calc ul li.btn-3 a:hover{background-position:0 -123px;}
#formula {position:absolute;top:20px;background:none;border:0;font:700 12px/1.5 arial;width:280px;padding:3px 15px 0 5px;text-align:right;}
</style>
<div id= "Nav_title" >
<a href= "http://jsq.204u.com" > Online calculator </a>
</div>
<script>
Window.onload = function ()
{
var Ocalc = document.getElementById ("calc");
var AA = Ocalc.getelementsbytagname ("a");
var ainput = ocalc.getelementsbytagname ("input") [0];
var Oformula = document.getElementById ("formula");
var s = false;
var i = 0;

for (i = 0; i < aa.length; i++) {
Aa[i].onfocus = function ()
{
This.blur ()
};
Aa[i].onclick = function ()
{
Switch (this.innerhtml)
{
Case "C":
Ainput.value = 0;
Oformula.value = "";
Break
Case "%":
Count ("%")
Break
Case "÷":
Count ("/")
Break
Case "X":
Count ("*")
Break
Case "-":
Count ("-")
Break
Case "+":
Count ("+")
Break
Case "=":
s | | (Oformula.value + = Ainput.value);
Ainput.value = eval (oFormula.value.replace (/\%\/\*\-\+/, "));
Ainput.value = AInput.value.substr (0,10). Replace ("NaN", 0);
s = true;
Break
Case ".":
if (AInput.value.search (/[\.\%\/\*\-\+]/)! =-1)
Break
Default
S && (ainput.value = 0, Oformula.value = "", S = false);
AInput.value.length < && (Ainput.value = (Ainput.value + this.innerhtml). Replace (/^[0\%\/\*\-\+] (\d)/, "$ 1 "));
}
}
}

function count (a)
{


if (s)
{
Oformula.value = Ainput.value + A;
Ainput.value = A;
s = false;
}
Else
{
/[\%\/\*\-\+]$/.test (ainput.value) | | (Oformula.value + = Ainput.value);
Ainput.value = A;
/[\%\/\*\-\+]$/.test (oformula.value) | | (Oformula.value + = Ainput.value);
Oformula.value = OFormula.value.slice ( -1)! = a? OFormula.value.replace (/.$/,a): Oformula.value
}
}
}
</script>


<body>
<div id= "Calc" >
<p>js Calculator Code </p>
<input class= "F-text" type= "text" readonly= "readonly" maxlength= "9" value= "0"/>
<ul>
<li class= "btn-1" ><a href= "javascript:void (0)" >c</a></li>
<li class= "btn-1" ><a href= "javascript:void (0)" >%</a></li>
<li class= "btn-1" ><a href= "javascript:void (0)" >÷</a></li>
<li class= "btn-1" ><a href= "javascript:void (0)" >x</a></li>
<li><a href= "javascript:void (0)" >7</a></li>
<li><a href= "javascript:void (0)" >8</a></li>
<li><a href= "javascript:void (0)" >9</a></li>
<li class= "btn-1" ><a href= "javascript:void (0)" >-</a></li>
<li><a href= "javascript:void (0)" >4</a></li>
<li><a href= "javascript:void (0)" >5</a></li>
<li><a href= "javascript:void (0)" >6</a></li>
<li class= "btn-1" ><a href= "javascript:void (0)" >+</a></li>
<li><a href= "javascript:void (0)" >1</a></li>
<li><a href= "javascript:void (0)" >2</a></li>
<li><a href= "javascript:void (0)" >3</a></li>
<li class= "btn-2" ><a href= "javascript:void (0)" >=</a></li>
<li class= "btn-3" ><a href= "javascript:void (0)" >0</a></li>
<li><a href= "javascript:void (0)" >.</a></li>
</ul>
<input id= "formula" type= "text" readonly= "readonly" value= ""/>
</div>
</body>


The calculator interface is simple and generous, with addition, subtraction, multiplication, in addition to function, clear screen, priced and other functions!
Support IE browser, Sogou browser, Firefox browser, Google Chrome browser, such as mainstream browser, ready-to-use, no database, upload can be used!

Demo page: http://jsq.204u.com






Because the source code needs to load some background images to look good, please go to the following link to download the background image.



——————



Source: 204U software online calculator js source code Download






Online Calculator JS source code


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.