<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function yunsf(n){
var n1=parseInt(document.getElementById("num1").value);
var n2=parseInt(document.getElementById("num2").value);
var n3;
if(!isNaN(n1)||!isNaN(n2)){
switch(n){
case 1:
n3=n1+n2;
break;
case 2:
n3=n1-n2;
break;
case 3:
n3=n1*n2;
break;
case 4:
if(n2==0)
alert("除数不能为0!");
else
n3=n1/n2;
break;
}
document.getElementById("num3").value=n3;
}
else{
alert("请输入一个整数!");
}
}
</script>
</head>
<body>
<table width="274" border="1">
<tr>
<td width="94">第一个数:</td>
<td width="168">
<input type="text" name="num1" id="num1" /></td>
</tr>
<tr>
<td>第二个数:</td>
<td><input type="text" name="num2" id="num2" /></td>
</tr>
<tr>
<td colspan="2"> <input type="button" name="button" id="button" value="+" οnclick="javascript:yunsf(1);"/>
<input type="button" name="button2" id="button2" value="-" οnclick="javascript:yunsf(2);"/>
<input type="button" name="button3" id="button3" value="*" οnclick="javascript:yunsf(3);"/>
<input type="button" name="button3" id="button4" value="/" οnclick="javascript:yunsf(4);"/> </td>
</tr>
<tr>
<td>结果</td>
<td><input type="text" name="num3" id="num3" /></td>
</tr>
</table>
</body>