<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<title>6编程练习</title>
</head>
<body>
<script type="text/javascript">
function tong(){
var a = parseInt(document.getElementById)("txt1").value);
var b = document.getElementById)("select").value;
var c = parseInt(document.getElementById)("txt2").value);
var result;
switch(b){
case "+":
result = a + c;
break;
case "-":
result = a - c;
break;
case "*":
result = a * c;
break;
default:
result = a / c;
}
document.getElementById("adc").value = result;
}
</script>
<input type="text" id="txt1"/>
<select id="select">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" id="txt2"/>
<input type="button" value="=" onclick="tong()"/>
<input type="text" id="adc"/>
</body>
</html>
尐兀
相关分类