function count(){ var one =parseInt(document.getElementById("txt1").value)//获开第一个输入框的值 var two=parseInt(document.getElementById("txt2").value) //获开第二个输入框的值 var three = document.getElementById("select").value; //获开选择框的值 var four= ""; switch(three) { case '+': four =one+two break; case '-': four=one-two break; case '*': four=one*two break; case '/' four =one/two default undefined//获开通过下拉框来选择的值来改变加减乘除的运算法则 } document.getElementById("fruit").value = four;//设置结果输入框的值 } } </script> + - * /