I have a gridview having text boxes in template fields and buttons in footer, on footer button click i want to calculate the total of template column's having textboxes but i am not able to get textboxe's value.i am using following code in my aspx page
function ValidateTotalPercentage(CellNo)
{
开发者_开发百科
var ages = 0;
var weights = 0;
var benchpresses = 0;
//reference the rows you want to add
//this will not include the header row
var rows = $("#<%=grdMaterialPercentage.ClientID%> tr:gt(0)");
rows.children("td:nth-child(" + CellNo + ")").each(function () {
//each time we add the cell to the total
var str= $(this).html();
alert(str.toString().indexOf("value"));
});
alert(ages);
return false;
}
Thanks
Try this
function ValidateTotalPercentage(CellNo) {
var ages = 0;
var weights = 0;
var benchpresses = 0;
//reference the rows you want to add
//this will not include the header row
var rows = $("#<%=grdMaterialPercentage.ClientID%> tr:gt(0)").not("tr:last");
rows.children("td:nth-child(" + CellNo + ")").each(function () {
//each time we add the cell to the total
//If the text field accepts decimal values then use parseFloat to convert the number
ages = ages + parseInt($(this).find("input").val());
//alert(str.toString().indexOf("value"));
});
alert(ages);
return false;
}
精彩评论