Completely Free .NET word API

Forums » .NET » ASP.NET »

addition of two numbers in textboxes to display in 3rd textbox

Posted Date: 16 Oct 2008      Posted By:: sarayu     Member Level: Gold  Member Rank: 139     Points: 1   Responses: 5

HI all

here i have three text boxes and i want to add first two text box numbers and need to disply in third text box. and my constraint is with out button press.

My requirement is by entering the two numbers in first and second text box , automatically the total value will display in third text box.

if possible please give me code.

i want this in java script or c# code like text box text changed event.

thank you.....


#307443    Author: gomathinayagam      Member Level: Gold      Member Rank: 0     Date: 16/Oct/2008   Rating: 3 out of 53 out of 53 out of 5     Points: 3

<input name="textfield2" type="text" class="textBox" id="textfield2" s
onblur="addtxt()" value="" />

<script language="javascript" type="text/javascript">
function addtxt() {

var num1 = document.getElementById('textfield1').value;
var num2 =document.getElementById('textfield2').value;
intnum1 = parseInt(num1);
intnum2 = parseInt(num2);
document.getElementById('textfield3').value =intnum1 + intnum2;

Gomathi Nayagam

Please Rate my answer if it has helpful to you

#307452    Author: Swetha      Member Level: Gold      Member Rank: 0     Date: 16/Oct/2008   Rating: 4 out of 54 out of 54 out of 54 out of 5     Points: 6

Enter A:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
Enter B:<asp:TextBox ID="TextBox2" runat="server" OnChange="CalculateSum(this)"></asp:TextBox>
Result : <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
function CalculateSum(txtObject)
var txt1 = document.getElementById('TextBox1');
var txt3 = document.getElementById('TextBox3');
if(txtObject !=null && txt1 != null && txt3 != null)
if(txt1.value != '' && txtObject.value != '')
txt3.value = parseInt(txt1.value) + parseInt(txtObject.value);

#307454    Author: sarayu      Member Level: Gold      Member Rank: 139     Date: 16/Oct/2008   Rating: 2 out of 52 out of 5     Points: 2

Hi gomathinayagam,

thank you for your fast response..

its working fine.

But when i entering the second value its giving the result 3rd text box before entering all digits.

please help me out....

thank you....

#307462    Author: gomathinayagam      Member Level: Gold      Member Rank: 0     Date: 16/Oct/2008   Rating:     Points: -20

[Response removed by Admin for invalid response to the thread or violation of forum policies.]

#307509    Author: seenu      Member Level: Gold      Member Rank: 0     Date: 16/Oct/2008   Rating: 3 out of 53 out of 53 out of 5     Points: 3

Post Reply     

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.

  • Return to Discussion Forum
  • Start new thread

  • Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Suresh G
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India