<html>
<head>
<script type = "text/javascript">
function calculator(){
var f=parseInt(document.getElementById("a").value);
var s=parseInt(document.getElementById("b").value);
var op=document.getElementById("c").value;
if (op=="+"){
document.writeln("ADDITION OF TWO NUMBERS="+(f+s));
}
if (op=="-"){
document.writeln("subtraction OF TWO NUMBERS="+(f-s));
}
if (op=="*"){
document.writeln("product OF TWO NUMBERS="+(f*s));
}
if (op=="/"){
document.writeln("Division OF TWO NUMBERS="+(f/s));
}
}
</script>
</head>
<body>
<form name="calc">
ENTER FIRST NUMBER:<Input type="text" id="a" name="a"><br>
ENTER SECOND NUMBER:<Input type="text" id="b" name="b"><br>
ENTER the operation to perform:<Input type="text" id="c" name="c"><br>
<Input type="button" onclick="calculator();return false;" value="CLICK ME"><br>
</form>
</body>
</html>
No comments:
Post a Comment