第六章的编程练习,求大神指点
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>事件练习</title>
<script type="text/javascript">
function count(){
var text1=parseInt(document.getElementById("text1").value);
var select=parseInt(document.getElementById("select").value);
var text2=parseInt(document.getElementById("text2").value);
var result='';
switch(select)
{
case '+':
result=text1+text2;break;
case "-":
result=text1-text2;break;
case "*":
result=text1*text2;break;
case "/":
result=text1/text2;break;
}
document.getElementById("text3").value=result;
}
</script>
</head>
<body>
<form action="">
<input type="text" id="text1"/>
<select id="select">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" id="text2"/>
<input type="button" value="=" onclick = "count()" />
<input type="text" id="text3"/>
</form>
</body>
</html>