<html>
<head >
<title>
</title>
<script type="text/javascript">
var a, b, c;
function Addition()
{
a = document.getElementById('txtNum1').value;
b = document.getElementById('txtNum2').value;
c = parseInt(a) +
parseInt(b);
document.getElementById('txtresult').value = c;
}
function Subtraction() {
a = document.getElementById('txtNum1').value;
b = document.getElementById('txtNum2').value;
c = parseInt(a) -
parseInt(b);
document.getElementById('txtresult').value = c;
}
function Multiplication() {
a = document.getElementById('txtNum1').value;
b = document.getElementById('txtNum2').value;
c = parseInt(a) *
parseInt(b);
document.getElementById('txtresult').value = c;
}
function Division() {
a = document.getElementById('txtNum1').value;
b = document.getElementById('txtNum2').value;
c = parseInt(a) /
parseInt(b);
document.getElementById('txtresult').value = c;
}
</script>
</head>
<body>
<form name="Calculator">
<div>
<div align="center"><h1 style="color:green">Mini Calculator</h1></div>
<table>
<tr>
<td><input type="text" id="txtNum1" name="Number1" /> </td>
<td><input type="button" id="btn1" value="+" onclick="Addition()"/>
<br />
<input type="button" id="btn2" value="-" onclick="Subtraction()" /><br />
<input type="button" id="btn3" value="X" onclick="Multiplication()" /><br />
<input type="button" id="btn4" value="/" onclick="Division()" />
</td><td> <input type="text" id="txtNum2" name="Number2" /></td><td> = </td>
<td><input type="text" id="txtresult" name="total" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>
output:
No comments:
Post a Comment