Copy Code code as follows:
<! 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=gb2312 "/>
<title> Calculator </title>
<script language= "javascript" type= "Text/javascript" >
var Clearflag=false;
function Getnum (num) {
alert (num);
var Objresult=document.getelementbyid ("result");
if (Clearflag) {
Objresult.value= "";
Clearflag=false;
}
alert (Objresult);
Objresult.value+=num;
}
function GetResult () {
var Objresult=document.getelementbyid ("result");
Objresult.value=objresult.value+ "=" +eval (objresult.value);
Clearflag=true;
}
</script>
<body>
<table width= "border=" 1 "cellpadding=" 2 ">
<tr>
<TD colspan= "4" ><input type= "text" name= "result" id= "result" size= "></td>"
</tr>
<tr>
<TD width= "><input type=" button "value=" 1 "onclick=" Getnum (1) "></td>
<TD width= "><input type=" button "value=" 2 "onclick=" Getnum (2) "></td>
<TD width= "Wuyi" ><input type= "button" value= "3" onclick= "Getnum (3)" ></td>
<TD width= "><input type=" button "value=" + "onclick=" getnum (' + ') "></td>
</tr>
<tr>
<td><input type= "button" value= "4" onclick= "Getnum (4)" ></td>
<td><input type= "button" value= "5" onclick= "Getnum (5)" ></td>
<td><input type= "button" value= "6" onclick= "Getnum (6)" ></td>
<td><input type= "button" value= "-" onclick= "Getnum ('-')" ></td>
</tr>
<tr>
<td><input type= "button" value= "7" onclick= "Getnum (7)" ></td>
<td><input type= "button" value= "8" onclick= "Getnum (8)" ></td>
<td><input type= "button" value= "9" onclick= "Getnum (9)" ></td>
<td><input type= "button" value= "*" onclick= "getnum (' * ')" ></td>
</tr>
<tr>
<td><input type= "button" value= "0" onclick= "getnum (0)" ></td>
<td><input type= "button" value= ". "Onclick=" Getnum ('. ') " ></td>
<td><input type= "button" value= "=" onclick= "GetResult ()" ></td>
<td><input type= "button" value= "/" onclick= "getnum ('/')" ></td>
</tr>
</table>
</body>
PS: Here again for you to recommend two online calculator this site, are implemented with JS, and powerful, I believe that in-depth understanding of JavaScript math and web design will help:
Online Standard calculator:http://tools.jb51.net/jisuanqi/jsq
Online Science calculator:Http://tools.jb51.net/jisuanqi/jsqkexue