到底你哪错了啊????
<!DOCTYPE html>
<html>
<head>
<title> 事件</title>
<script type="text/javascript">
function count(){
var tonum1=document.getElementById("txt1").value;
var tonum2=document.getElementById("txt2").value;
var toSelect=document.getElementById("select").value;
var toFruit="";
switch(toSelect){
case "+":
toFruit = parseFloat(tonum1) + parseFloat(tonum2);
break;
case "-":
toFruit = parseFloat(tonum1) * parseFloat(tonum2);
break;
case "*":
toFruit = parseFloat(tonum1) - parseFloat(tonum2);
break;
default:
toFruit = parseFloat(tonum1) / parseFloat(tonum2);
}
document.getElementById("fruit").value = toFruit;
}
</script>
</head>
<body>
<input type='text' id='txt1' />
<select id='select'>
<option value='+'>+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type='text' id='txt2' />
<input type='button' value=' = ' oncilck='count()'/>
<input type='text' id='fruit' />
</body>
</html>