I am having my girdivew as follows
http://www.eggheadcafe.com/FileUpload/426776068/Grid1.png
After selecting customer it will be as follows
http://www.eggheadcafe.com/FileUpload/426776068/main.png
http://www.eggheadcafe.com/FileUpload/426776068/customer.png
http://www.eggheadcafe.com/FileUpload/426776068/Selecting%20Item.png
http://www.eggheadcafe.com/FileUpload/426776068/quantity.png
http://i.stack.imgur.com/QUjzG.png
I would like to display the sum in the label available on the from
This is what I have written to display Amount in the amount textbox
<script type="text/javascript">
function multiplication(txtQuantity, txtRate, txtAmount) {
var weight = document.getElementById(txtQuantity).value;
var rate = document.getElementById(txtRate).value;
document.getElementById(txtAmount).value = weight * rate;
var amnt = 0;
var Grid_Table = document.getElementById('<%= grdInvoice.ClientID %>');
for (var row = 1; row < Grid_Table.rows.length; row++) {
var qty = 0;
for (var col = 0; col < Grid_Table.rows[row].cells.length; col++) {
var cellcollectin = Grid_Table.rows[row].cells[col];
for (var j = 0; j < cellcollectin.childNodes.length; j++) {
if (cellcollectin.childNodes[j].type == "text") {
if (cellcollectin.childNodes[j].name == "txtAmount") {
alert("Success");
if (cellcollectin.childNodes[j].value != "") {
qty = parseInt(cellcollectin.childNodes[j].value);
amnt = amnt + qty;
}
}
}
}
}
}
document.getElementById('<%= lblTotal.ClientID %>').innerHtml = amnt.toString();
}
</script>
This is how I called the script in code
for (int i = 0; i < grdInvoice.Rows.Count; i++)
{
TextBox curTexbox = grdInvoice.Rows[i].Cells[1].FindControl("txtQuantity") as TextBox;
TextBox curTexbox1 = grdInvoice.Rows[i].Cells[3].FindControl("txtRate") as TextBox;
TextBox curTexbox2 = grdInvoice.Rows[i].Cells[4].FindControl("txtAmount") as TextBox;
curTexbox2.Attributes.Add("readonly", "readonly");
Session["lbl"] = curTexbox2;
curTexbox2.Attributes.Add("onBlur", "return multiplication('" + curTexbox.ClientID + "','" + curTexbox1.ClientID + "','" + curTexbox2.ClientID + "')");
}
But unable to display the total in the label can you help me