为什么 var s=document.getElementById("fruit").value; s=结果,不能在文本框里显示?
var oTxt1=document.getElementById("txt1").value;
//获取第一个输入框的值
var oTxt2=document.getElementById("txt2").value;
var oSlt = document.getElementById("select").value;
var result = "";
switch(oSlt) {
case "+":
result = parseFloat(oTxt1) + parseFloat(oTxt2);
break;
case "-":
result = parseFloat(oTxt1) - parseFloat(oTxt2);
break;
case "*":
result = parseFloat(oTxt1) * parseFloat(oTxt2);
break;
default:
result = parseFloat(oTxt1) / parseFloat(oTxt2);
}
var s=document.getElementById("fruit").value;
s= result;//不能在文本框里显示
要直接用document.getElementById("fruit").value=result;