Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, is there anyone who can help me to solve my problem about getting the sum of my textboxes?

i have 4 textbox in each row, what i want is to get the sum of the last column textboxes?

here is my code:

XML
<input type="text" id="txtParticulars" name="txtParticulars" value="'.$Particular.'"><input type="text" id="txtQty'.$RSD_No.'" value ="'.$Quantity.'" readonly>
<input type="text" id="txtUP" name="txtUP'.$RSD_No.'" /><input type="text" id="txtTotal'.$RSD_No.'" readonly>
Total:<input type="text" id="txtGrandTotal" class="add" readonly />




C#
function calc(row)
{
    var in1=document.getElementById('txtQty'+row).value;
    var in2=document.getElementById('txtUP'+row).value;
    var in3=in1*in2;
    var total = document.getElementById('txtTotal'+row).value=in3.toFixed(2);
}
Posted

1 solution

Use firebug or Developer tools to see the elementid, Once you have the element Id document.getElementById return your element.
perseInt() parses string and returns integer
JavaScript
var in1=document.getElementById('YourElementIdForQty').value;
var in2=document.getElementById('YourElementIdForUP').value;
var in3=(parseInt(in1)*parseInt(in2)).toFixed(2);

document.getElementById('YourElementIdFotTotal').value=in3;
var total =int3;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900