level 1
jbweb2006
楼主
<html>
<head>
<title>计算器</title>
<meta http-equi="content-type" content="text/html; charset=GB2312">
<script>
function compute(obj)
{
obj.expr.value = eval(obj.expr.value);
}
function enter(obj,string)
{
obj.expr.value += string;
}
var zero="0";
var one="1";
var two="2";
var three="3";
var four="4";
var five="5";
var six="6";
var seven="7";
var eight="8";
var nine="9";
var jia="+";
var jian="-";
var cheng="*";
var chu="/";
var dian=".";
</script>
</head>
<center><h1>一个老掉牙的Js编的计算器</h1></center>
<div style="text-align: center;">
<form>
<input type="text" name="expr" action="compute(this.form)">
<br><br>
<input type="button" value="1" onclick="enter(this.form,one)">
<input type="button" value="2" onclick="enter(this.form,two)">
<input type="button" value="3" onclick="enter(this.form,three)">
<input type="button" value="+" onclick="enter(this.form,jia)">
<br><br>
<input type="button" value="4" onclick="enter(this.form,four)">
<input type="button" value="5" onclick="enter(this.form,five)">
<input type="button" value="6" onclick="enter(this.form,six)">
<input type="button" value="-" onclick="enter(this.form,jian)">
<br><br>
<input type="button" value="7" onclick="enter(this.form,seven)">
<input type="button" value="8" onclick="enter(this.form,eight)">
<input type="button" value="9" onclick="enter(this.form,nine)">
<input type="button" value="*" onclick="enter(this.form,cheng)">
<br><br>
<input type="button" value="0" onclick="enter(this.form,zero)">
<input type="button" value="/" onclick="enter(this.form,chu)">
<input type="button" value="AC" onclick="enter(form.reset())">
<input type="button" value="." onclick="enter(this.form,dian)">
<br><br>
<input type="button" value="=" onclick="compute(this.form)">
</form>
</div>
</html>
2018年08月05日 19点08分
1
<head>
<title>计算器</title>
<meta http-equi="content-type" content="text/html; charset=GB2312">
<script>
function compute(obj)
{
obj.expr.value = eval(obj.expr.value);
}
function enter(obj,string)
{
obj.expr.value += string;
}
var zero="0";
var one="1";
var two="2";
var three="3";
var four="4";
var five="5";
var six="6";
var seven="7";
var eight="8";
var nine="9";
var jia="+";
var jian="-";
var cheng="*";
var chu="/";
var dian=".";
</script>
</head>
<center><h1>一个老掉牙的Js编的计算器</h1></center>
<div style="text-align: center;">
<form>
<input type="text" name="expr" action="compute(this.form)">
<br><br>
<input type="button" value="1" onclick="enter(this.form,one)">
<input type="button" value="2" onclick="enter(this.form,two)">
<input type="button" value="3" onclick="enter(this.form,three)">
<input type="button" value="+" onclick="enter(this.form,jia)">
<br><br>
<input type="button" value="4" onclick="enter(this.form,four)">
<input type="button" value="5" onclick="enter(this.form,five)">
<input type="button" value="6" onclick="enter(this.form,six)">
<input type="button" value="-" onclick="enter(this.form,jian)">
<br><br>
<input type="button" value="7" onclick="enter(this.form,seven)">
<input type="button" value="8" onclick="enter(this.form,eight)">
<input type="button" value="9" onclick="enter(this.form,nine)">
<input type="button" value="*" onclick="enter(this.form,cheng)">
<br><br>
<input type="button" value="0" onclick="enter(this.form,zero)">
<input type="button" value="/" onclick="enter(this.form,chu)">
<input type="button" value="AC" onclick="enter(form.reset())">
<input type="button" value="." onclick="enter(this.form,dian)">
<br><br>
<input type="button" value="=" onclick="compute(this.form)">
</form>
</div>
</html>