<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 简单计算器</TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="JavaScript">
var m=0;
//是第一操作数
function SetExp(str){
if(m==1)
//根据m值判定结果是否为第一操作数
{
document.Nform.result.value="";
m=0;
}
else(m==0)
{
document.Nform.result.value+=str;
}
}
function Cal(result){
var str=document.Nform.result.value;
document.Nform.result.value=eval(str);
m=1;
}
function Clear(){
document.Nform.result.value="";
}
</script>
</HEAD>
<BODY>
<center>
<h2></h2>
<form name=Nform method=get>
<table border="1" bordercolor="#003300">
<tr>
<td colspan="3">
<input type=text name="result">
</td>
</tr>
<tr align="center">
<td>
<input type="button" value="1" onClick="SetExp('1')">
</td>
<td>
<input type="button" value="2" onClick="SetExp('2')">
</td>
<td>
<input type="button" value="3" onClick="SetExp('3')">
</td>
</tr>
<tr align="center">
<td>
<input type="button" value="4" onClick="SetExp('4')">
</td>
<td>
<input type="button" value="5" onClick="SetExp('5')">
</td>
<td>
<input type="button" value="6" onClick="SetExp('6')">
</td>
</tr>
<tr align="center">
<td>
<input type="button" value="7" onClick="SetExp('7')">
</td>
<td>
<input type="button" value="8" onClick="SetExp('8')">
</td>
<td>
<input type="button" value="9" onClick="SetExp('9')">
</td>
</tr>
<tr align="center">
<td>
<input type="button" value="0" onClick="SetExp('0')">
</td>
<td>
<input type="button" value="." onClick="SetExp('.')">
</td>
<td>
<input type="button" value="C" onClick="Clear()">
</td>
</tr>
<tr align="center">
<td>
<input type="button" value="+" onClick="SetExp('+')">
</td>
<td>
<input type="button" value="-" onClick="SetExp('-')">
</td>
<td>
<input type="button" value="*" onClick="SetExp('*')">
</td>
</tr>
<tr align="center">
<td>
<input type="button" value="/" onClick="SetExp('/')">
</td>
<td colspan="2">
<input type="button" value="=" onClick="Cal()">
</td>
</tr>
</table>
</form>
</center>
</BODY>
</HTML>