adding two values and dispaly into third textbox

Ankitsrist
Posted by Ankitsrist under JavaScript category on | Points: 40 | Views : 2471
hello techies,
lets see how to add two values from two different textboxes and display in third textbox...write the following code and check yourself

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript" language="javascript ">
function adding()
{
var a = document.getElementById("text1").value;
var b = document.getElementById("text2").value;

var c = parseInt(a)+ parseInt(b);
document.getElementById("text3").value = c;
//document.write("parseInt(a)+b = "+c);
}
</script>

first number &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<input id="text1" onchange="adding()" />
<br />
<br />
Second Number &nbsp; &nbsp; &nbsp; &nbsp;
<input id="text2" onchange="adding()" />
<br />
<br />
result &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
&nbsp;
<input id="text3" />

</asp:Content>

thanks
ankit saxena

Comments or Responses

Login to post response