<html>
<head>
</head>
<body>
<script type="text/javascript">
function all(value1) {
var a1 = parseInt(document.getElementById("n1").value);
var a2 = parseInt(document.getElementById("n2").value);
var a3;
switch(value1)
{
case '+' : a3=a1+a2; break;
case '-' : a3=a1-a2; break;
case '*' : a3=a1*a2; break;
case '/' : a3=a1/a2; break;
}
document.getElementById("ans").value=a3;
return;
}
</script>
<table align="center">
<tr>
<td colspan="2">
<input type="text" id="n1"/>
</td>
<td colspan="2">
<input type="text" id="n2"/>
</td>
</tr>
<tr>
<td>
<input type="button" value="+" id="+but" onclick=" return all(this.value)" value="+"/>
</td>
<td>
<input type="button" value="-" id="-but" onclick=" return all(this.value)" value="-"/>
</td>
<td>
<input type="button" value="*" id="*but" onclick=" return all(this.value)" value="*"/>
</td>
<td>
<input type="button" value="/" id="/but" onclick=" return all(this.value)" value="/"/>
</td>
</tr>
<tr>
<td colspan="4">
<input type="text" id="ans" readonly="readonly"/>
</td>
</tr>
</table>
</body>
</html>
No comments:
Post a Comment