使用jquery的gridview文本框列和

时间:2011-08-02 04:38:29

标签: jquery gridview

我有一个gridview在模板字段中有文本框和页脚中的按钮,在页脚按钮上单击我想要计算模板列的总数有文本框但我无法获得textboxe的值。我正在使用下面的代码aspx页面

 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;
    }

由于

1 个答案:

答案 0 :(得分:0)

试试这个

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;
}