In this article I am going to show how to add 2 numeric numbers using java script:
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
script
type
=
"text/javascript"
src
=
"http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"
></
script
>
<
script
type
=
"text/javascript"
>
$(function() {
$('#btnAdd').click(function() {
var value1 = $('#txtFirstNumber').val();
var value2 = $('#txtSecondNumber').val();
var sum = parseInt(value1, 10) + parseInt(value2, 10);
$('#msg').html(sum);
});
});
</
script
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
First Number :<
input
id
=
"txtFirstNumber"
type
=
"text"
/><
br
/>
Second Number:<
input
id
=
"txtSecondNumber"
type
=
"text"
/>
<
input
id
=
"btnAdd"
type
=
"button"
value
=
"Add"
/>
<
br
/>
<
span
id
=
"msg"
></
span
>
</
form
>
</
body
>
</
html
>