<script type="text/javascript">
/* function count(){
//获取第一个输入框的值
//获取第二个输入框的值
//获取选择框的值
//获取通过下拉框来选择的值来改变加减乘除的运算法则
//设置结果输入框的值
}*/
function count(){
var number = document.getElementById("txt1").value;
var number2 = document.getElementById("txt2").value;
var xuanze = document.getElementById("select").value;
var result = "";
if(xuanze == "+")
{
var result = parseInt(number) + parseInt(number2);
} else if(xuanze == "-")
{
var result = parseInt(number) - parseInt(number2);
} else if (xuanze == "*")
{
var result = parseInt(number) + parseInt(number2);
} else
{
var result = parseInt(number) + parseInt(number2);
}
document.getElementById("fruit").value = result;
}
</script>
我运行你的代码没问题,除了改+ - * /
看看你的select的value,+-*/应该不是value吧。alert取到的xuanze看看