You must Sign In to post a response.

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

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    16 Oct 2008 Member Level: Gold   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  16 Oct 2008 Member Level: Gold   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  16 Oct 2008 Member Level: Gold   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    16 Oct 2008 Member Level: Gold   Points : -20

[Response removed by Admin. Read forum policies.]

Gomathi Nayagam

Please Rate my answer if it has helpful to you

#307509    Author: seenu    16 Oct 2008 Member Level: Gold   Points : 3


Delete Attachment

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.