function count(){
var oTxt1 = document.getElementById("txt1").value;
var oTxt2 = document.getElementById("txt2").value;
var oSlt = document.getElementById("select").value;
var result = " ";
switch(oSlt) {
case "+":
result = parseInt(oTxt1) +parseInt(oTxt2);
break;
case "-":
result = parseInt(oTxt1) - parseInt(oTxt2);
break;
case "*":
result = parseInt(oTxt1) * parseInt(oTxt2);
break;
default:
result =parseInt(oTxt1) / parseInt(oTxt2);
}
document.getElementById("fruit").value = result;
}
因为你要在按键那写个onclick调用函数 <input type='button' value=' = ' onclick="count()" />