<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet"type="text/css"href="styles/cal.css"/>
<title>计算器</title>
<script language="javascript">
var num;
function fun()
{
f1.txt.value+='0';
num=0;
}
function fun1()
{
f1.txt.value+='1';
num=1;
}
function fun2()
{
f1.txt.value+='2'
num=2;
}
function fun3()
{
f1.txt.value+='3';
num=3;
}
function fun4()
{
f1.txt.value+='4';
num=4;
}
function fun5()
{
f1.txt.value+='5';
num=5;
}
function fun6()
{
f1.txt.value+='6';
num=6
}
function fun7()
{
f1.txt.value+='7';
num=7;
}
function fun8()
{
f1.txt.value+='8';
num=8;
}
function fun9()
{
f1.txt.value+='9';
num=9;
}
function fun_add()
{
f1.txt.value+='+';
}
function fun_sub()
{
f1.txt.value+='-';
}
function fun_mul()
{
f1.txt.value+='*';
}
function fun_div()
{
f1.txt.value+='/';
}
function fun_recip()
{
f1.txt.value='1/'+f1.txt.value;
f1.txt.value=eval(f1.txt.value);
}
function fun_perc()
{
f1.txt.value=f1.txt.value+'/100';
f1.txt.value=eval(f1.txt.value);
}
function fun_clear()
{
f1.txt.value='';
}
function fun_eql()
{
f1.txt.value=eval(f1.txt.value);
}
function fun_bac()
{
f1.txt.value=(-1)*f1.txt.value;
}
function fun_Backspace()
{
f1.txt.value=f1.txt.value.slice(0,-1);
}
function fun_point()
{
f1.txt.value+='.';
}
function fun_CE()
{
f1.txt.value='0';
}
</script>
</head>
<body>
<div id="containter">
<div id="title">
<h1>计算器</h1>
</div>
<div id="calculator">
<div id="menu">
<a href="#">查看(V)</a>
<a href="#">编辑(E)</a>
<a href="#">帮助(H)</a>
</div>
<div id="operate">
<form name="f1">
<div id="field">
<div id="screen"><input type="text" name="txt" readonly="readonly" value="0"></input></div>
</div>
<div id="bar">
<input type="button" name="MC" value="MC"></input>
<input type="button" name="MR" value="MR"></input>
<input type="button" name="MS" value="MS"></input>
<input type="button" name="M+" value="M+"></input>
<input type="button" name="M-" value="M-"></input>
<input type="button" name="<——" value="<——" onClick="fun_Backspace()"></input>
<input type="button" name="CE" value="CE" onClick="fun_CE()"></input>
<input type="button" name="C" value="C" onClick="fun_clear()"></input>
<input type="button" name="+/-" value="+/-" onClick="fun_bac()"></input>
<input type="button" name="~" value="~"></input>
<input type="button" name="7" value="7" onClick="fun7()"></input>
<input type="button" name="8" value="8" onClick="fun8()"></input>
<input type="button" name="9" value="9" onClick="fun9()"></input>
<input type="button" name="/" value="/" onClick="fun_div()"></input>
<input type="button" name="%" value="%" onClick="fun_perc()"></input>
<input type="button" name="4" value="4" onClick="fun4()"></input>
<input type="button" name="5" value="5" onClick="fun5()"></input>
<input type="button" name="6" value="6" onClick="fun6()"></input>
<input type="button" name="*" value="*" onClick="fun_mul()"></input>
<input type="button" name="1/x" value="1/x" onClick="fun_recip()"></input>
<input type="button" name="1" value="1" onClick="fun1()"></input>
<input type="button" name="2" value="2" onClick="fun2()"></input>
<input type="button" name="3" value="3" onClick="fun3()"></input>
<input type="button" name="-" value="-" onClick="fun_sub()"></input>
<span id="dengyu"><input type="button" name="=" value="=" onClick="fun_eql()"></input></span>
<span id="ling"><input type="button" name="0" value="0" onClick="fun()"></input></span>
<input type="button" name="." value="." onClick="fun_point()"></input>
<input type="button" name="+" value="+" onClick="fun_add()"></input>
</div>
</form>
</div>
</div>
</div>
</body>
</html>