Arithmetic operator

Sunny.Sagar
Posted by Sunny.Sagar under JavaScript category on | Points: 40 | Views : 321
 <script language="javascript" type="text/javascript">
function Sum() {
var a = document.getElementById("A").value;
var b = document.getElementById("B").value;
var result = parseInt(a) + parseInt(b);
alert(result);
}
</script>
Enter two digit:
<input type="text" id="A" name="A" />
+
<input type="text" id="B" name="A" />
<input type="button"name="btnAdd"value="Add"onclick="Sum()" />


For addition in Javascript code approch this code ..In the same way for subtract /division / multiplication change the code in "var result - / \ / * "

Run the code in the broswer

Comments or Responses

Login to post response