<script type="text/javascript">
function count(){
var x=document.getElementById("txt1").value
var y=document.getElementById("txt2").value
var z=document.getElementById("select").value
var s=document.getElementById("fruit").value;
switch(z)
{
case 1;
s=parseInt(x)+parseInt(y);
break;
caee 2;
s=parseInt(x)-parseInt(y);
break;
case 3;
s=parseInt(x)*parseInt(y);
break;
default;
s=parseInt(x)/parseInt(y);
}
}
</script>
</head>
<body>
<input type='text' id='txt1' />
<select id='select'>
<option value='+'>+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
为什么case值与select值不匹配,计算也能成功?
default;
s=parseInt(x)/parseInt(y);
会运算这个
代码不完整
提问首先要确保代码正确吧。。。这个代码你确定正确么