问答详情
源自:6-11 编程练习

运行不了,求解答

<!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>


提问者:吃瓜小夏 2015-12-15 13:53

个回答

  • Caballarii
    2015-12-15 13:55:54
    已采纳

    default后面的冒号你打成中文的了

  • lynhao
    2015-12-15 13:57:57

     default:
                c=parseInt(a)/parseInt(b);
                分号的半角写成全角了哦~      :-->: