計算器無法計算結果,哪里出錯了?
<!DOCTYPE html>
<html>
?<head>
? <title> 事件</title>?
? <script type="text/javascript">
?? function count(){
?? var a=document.getElementById("txt1").value;
?? var b=document.getElementById("ttxt2").value;
?? var s=document.getElementById("select").value;
?? var h="";
?? switch(s)
?? {
??????? case "+":
??????? he=parseInt(a)+parseInt(b);
??????? break;
??????? case "-":
??????? he=parseInt(a)-parseInt(b);
??????? break;
??????? case "*":
??????? he=parseInt(a)*parseInt(b);
??????? break;
??????? default;
??????? he=parseInt(a)/parseInt(b);
?? }
?? document.getElementById("fruit").value=h;
?? }
? </script>
?</head>
?<body>
?<input id="txt1"? type="text" />
?<select id="select">
??? <option type="+">+</option>
??? <option type="-">-</option>
??? <option type="*">*</option>
??? <option type="/">/</option>
?</select>
?<input id="txt2"? type="text" />
?<input? type="button" value="=" onClick="count()"/>
?<input id="fruit"? type="text" />
?</body>
</html>
2016-09-24
變量定義錯誤
