用JavaScript写一个简单的计算器
<html>
<head>
<title>简单计算器</title>
<script>
function doCal(){
var value1=parseInt(document.getElementById("value1").value);
var flag=document.getElementById("value1").value
var value1=parseInt(document.getElementById("value1").value);
eval("var s="+value1+flag+value2);
document.getElementById("result").innerHTML="<font color='red'>"+s+"</font>";
}
</script>
</head>
<body>
<h1>简单计算器<h1>
<hr>
<input type="text" name="value1" id="value1">
<select name="flag">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" name="value2" id="value2">
<input type="button" value"=" onclick="doCal();">
<span id="result"></span>
</body>
</html>