<!DOCTYPE html>
<html>
<head>
<title>实现计算功能</title>
</head>
<body>
<script type="text/javascript">
function count()
{var a=document.getElementById("t1").value;
var b=document.getElementById("t2").value;
var c="";
var s=document.getElementById("select").value;
switch(s)
{case "+":
c=parseInt(a)+parseInt(b);
break;
case "-":
c=parseInt(a)-parseInt(b);
break;
case "*":
c=parseInt(a)*parseInt(b);
break;
default:
c=parseInt(a)/parseInt(b);
}
document.getElementById("t3").value=c;
}
</script>
<form>
<input id="t1" type="text" />
<select id="select">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input id="t2" type="text" />
<input type="button"value="=" onclick
="count()"/>
<input id="t3" type="text" />
</form>
</body>
</html>