日期:2014-05-16  浏览次数:20483 次

请求帮忙修改计算机代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="button/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<script type="button/javascript">
function compute(obj)
{obj.expr.value=eval(obj.expr.value)}
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 zero="0"
var plus="+"
var minus="-"
var multiply="*"
var divide="/"
var decimal="."
function enter(obj,string)
{obj.expr.value+=string}
function clear(obj)
{obj.expr.value=""}
</script>
<form name="calc">
<table border="1">
<td colspan="4"><input type="text" name="expr" size="30" action="conpute(this.form)" /></td>
<tr>
<td><input type="button" value="7" onclick="enter(this.form,seven)" /></td>
<td><input type="button" value="8" onclick="enter(this.form,eighe)" /></td>
<td><input type="button" value="9" onclick="enter(this.form,nine)" /></td>
<td><input type="button" value="/" onblur="enter(this.form divide)" /></td>
</tr>
<tr>
<td><input type="button" value="4" onclick="enter.(this.form,four)" /></td>
<td><input type="button" value="5" onclick="enter(this.form,five)" /></td>
<td><input type="button" value="6" onclick="enter(this.form,six)" /></td>
<td><input type="button" value="*" onclick="enter(this.form,multiply)" /></td>
<tr>
<td><input type="button" value="1" onclick="enter(this.form,one)" /></td>
<td><input type="button" value="2" onclick="enter(this.form,two)" /></td>
<td><input type="button" value="3" onclick="enter(this.form,three)" /></td>
<td><input type="button" value="-" onclick="enter(this.form,minus)" /></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="0" onclick="enter(this.form,zero)" /></td>
<td><input type="button" value="." onclick="enter(this.form,decimal)" /></td>
<td><input type="button" value="+" onclick="enter(this.form,plus)" /></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="=" onclick="compute(this.form,compute)" /></td>
<td><input type="button" value="AC" size="3" onclick="clear(this.form)" /></td>
</tr>
</table>
</body>
</html>


------解决方案--------------------
JScript code

function enter(obj,string){
  try{ obj.expr.value+=s