代码简写,供参考
function count(){
var a=parseInt(document.getElementById("txt1").value);
var b=parseInt(document.getElementById("txt2").value);
var c=document.getElementById("select").value;
var f=document.getElementById("fruit");
switch(c){
case '+':
f.value=a+b;
break;
case "-":
f.value=a-b;
break;
case "*":
f.value=a*b;
break;
case "/":
f.value=a/b;
break;
}
}
</script>