Struggling to calculate the total quantity from the gridview for checked row checkboxes? Having trouble accessing the checkbox control in your JavaScript? Below is the code snippet you provided, but it's not returning anything.
<table cellspacing="0" cellpadding="1" rules="all" border="1" id="grdView" style="background-color:#F2F4FF;width:100%;border-collapse:collapse;">
<tr>
<td align="center">
<span class="chkSelected" style="display:inline-block;border-style:None;"><input id="grdView_ctl02_chkSelect" type="checkbox" name="grdView$ctl02$chkSelect" /></span>
<input type="hidden" name="grdView$ctl02$hdDocId" id="grdView_ctl02_hdDocId" value="DO0002" />
<input type="hidden" name="grdView$ctl02$hdScope" id="grdView_ctl02_hdScope" value="Dlv" />
<input type="hidden" name="grdView$ctl02$hdDocType" id="grdView_ctl02_hdDocType" value="DO" />
<input type="hidden" name="grdView$ctl02$hdRefNo" id="grdView_ctl02_hdRefNo" />
<input type="hidden" name="grdView$ctl02$hdServiceType" id="grdView_ctl02_hdServiceType" />
<input type="hidden" name="grdView$ctl02$hdQty" id="grdView_ctl02_hdQty" />
<input type="hidden" name="grdView$ctl02$hdWeight" id="grdView_ctl02_hdWeight" />
</td>
</tr>
</table>
function calculateTotal()
{
var sum = 0.00;
var itemsum = 0.00;
var gv = document.getElementById('grdView');
for (var row = 1; row < gv.rows.length; row++) {
var cb = gv.rows[row].cells[0].childNodes[0].getElementsByTagName('input');
if (cb.checked) {
var quantity = gv.rows[row].cells[8].innerText;
try {
sum += new Number(quantity);
} catch (err) {
alert(quantity);
}
}
}
alert(sum.toString());
return false;
}