<html>
<head>
<script type="text/javascript">
function add()
{
var a=document.cal.num1.value;
var b=document.cal.num2.value;
var c=parseInt(a)+parseInt(b);
document.cal.res.value=c;
}
function sub()
{
var a=document.cal.num1.value;
var b=document.cal.num2.value;
var c=a-b;
document.cal.res.value=c;
}
function mul()
{
var a=document.cal.num1.value;
var b=document.cal.num2.value;
var c=a*b;
document.cal.res.value=c;
}
function div()
{
var a=document.cal.num1.value;
var b=document.cal.num2.value;
var c=a/b;
document.cal.res.value=c;
}
</script>
</head>
<body>
<form name="cal">
Enter 1st num:<input type="text" name="num1" /> <br/>
Enter 2nd num:<input type-="text" name="num2" /> <br/>
Select operation:
<select name="-please select-">
<option value="please select">-please select-</option>
<option value="addition" onclick="add()">addition</option>
<option value="subtraction" onclick="sub()">subtraction</option>
<option value="multiplication" onclick="mul()">multiplication</option>
<option value="division" onclick="div()">division</option>
</select>
Result= <input type="text" name="res" />
</form>
</body>
</html>


Reply With Quote
Bookmarks