不懂为什么中文会显示乱码... 还有为什么最后结果显示undifiened啊
<!DOCTYPE HTML>
<html>
<head>
<title> 计算器 </title>
<script type="text/javascript">
var a=document.getElementById("num1").value;
var b=document.getElementById("num2").value;
var c=document.getElementById("fuhao").value;
var d="";
function result(){
switch(c){
case "+":
d=parseInt(a)+parseInt(b);
break;
case "-":
d=parseInt(a)-parseInt(b);
break;
case "*":
d=parseInt(a)*parseInt(b);
break;
case "/":
d=parseInt(a)/parseInt(b);
break;
}
document.getElementById("sum").value=d;
}
</script>
</head>
<body>
<p>计算器</p>><br/>
<input type="text" id="num1" />
<select id="fuhao" value="+">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" id="num2" />
=
<input type="text" id="sum" /><br/>
<input type="button" value="计算" onclick="result()" /><br/>
</body>
</html>