Thursday, 26 June 2014

HTML program to add two numbers

HTML program to add two numbers 




<html>
<head>
<title>Addition</title>
<script type="text/javascript">
function addition()
{
var a =parseInt(document.getElementById("num1").value);
var b =parseInt(document.getElementById("num2").value);

var sum;
sum=a+b;
document.f1.sum.value=a+b;
alert(sum);
}
</script>
</head>
<body>
<form name="f1">
number1<input type="text" name="num1"><br>
number2<input type="text" name="num2"><br>
sum<input type="text" name="sum"><br>
<input type="button" value="add" onClick="addition()"><br>
<input type="reset" value="reset" >
</form>
</body>
</html>


No comments: