<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script>
function abc()
{
var tXt1=parseInt(document.getElementById('txt1').value);
var sel=documet.getElementById('select1').value;
var tXt2=parseInt(document.getElementById('txt2').value);
var result='';
switch(sel)
{
case '+':
result=tXt1+tXt2;
break;
case '-':
result=tXt1-tXt2;
break;
case '*':
result=tXt1*tXt2;
break;
case '/':
result=tXt1/tXt2;
break;
}
document.getElementById('txt3').value=result;
}
</script>
</head>
<body>
<input type="text" id="txt1">
<select id="select1" >
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" id="txt2" />
<input type="button" id="btn" value="=" onclick="abc()"/>
<input type="text" id="txt3" />
</body>
</html>
sel定义那里document打错了
function abc() { var tXt1=parseInt(document.getElementById('txt1').value); var sel=document.getElementById('select1').value; var tXt2=parseInt(document.getElementById('txt2').value); var result=''; switch(sel) { case '+': result=tXt1+tXt2; break; case '-': result=tXt1-tXt2; break; case '*': result=tXt1*tXt2; break; case '/': result=tXt1/tXt2; break; } document.getElementById('txt3').value=result; }
改了那个就可以了啊document
显示不了结果 求大神 帮助