Given Two text Boxes,I want add two numbers (using the two text boxes) and show the result in the thrid textbox (TextBox3) instantly i.e without pressing a asp.net button.
Number of Members
Male
Female
Sachin SinghPosted Mar 25, 2023, 4:59 PM
OK, use this then
Anandu G NathPosted Dec 27, 2023, 8:51 AM
Use this code it will work
Tuhin PaulPosted Mar 26, 2023, 9:42 AM
Try this code with optimization :
Jaya PrakashPosted Mar 25, 2023, 5:27 PM
Try My Version also
And in Code Behind
Garima BansalPosted Mar 25, 2023, 4:44 PM
Sachin Singh
Actually this works
$("[id*='Txt_MembersRegisteredFemale']").change(function () {
var sum = parseInt($("[id*='Txt_MembersRegisteredFemale']").val(), 10) + parseInt($("[id*='Txt_MembersRegisteredMale']").val(), 10);
$("[id*='totals']").val(sum);
});
But when i click on textbox 3 get the total value and its also editable, my scenerio is total value shown in textbox3 without clicking and its not editable
Sachin SinghPosted Mar 25, 2023, 5:56 AM
Yes , use jquery ,add jquery link on page then follow below
Garima BansalPosted Mar 24, 2023, 9:46 PM
i use onkeyup
function sum() {
var txtFirstNumberValue = document.getElementById('Txt_MembersRegisteredMale').value;
var txtSecondNumberValue = document.getElementById('Txt_MembersRegisteredFemale').value;
var result = parseInt(txtFirstNumberValue) + parseInt(txtSecondNumberValue);
if (!isNaN(result)) {
document.getElementById('total').value = result;
}
}
But not works, I need to any jquery link or anything else
Where i am doing wrong?