i am having trouble in calculation in grid, i made function but it works only on 1st row of grid and calculate total of first row of grid and then show this value in grand total textbox too. I want to do the same on all 4 rows of grid, what do i do? Kindly help. function CalculateTotal() { var Gtot = 0;
var RowCount = 0;
//var RowCount = document.getElementById('<%= hfGrdRows.ClientID%>').value - 0;
//alert(RowCount);
var grid = document.getElementById('<%= Grd_Exams.ClientID%>');
for (var i = 1; i < grid.rows.length ; i++) {
var cell = grid.rows[i].cells;
//var HTML = cell[0].innerHTML;
var Participation = document.getElementById('txtCl_Part').value - 0;
var Assgnmnt = document.getElementById('txtAssgnmnt').value - 0;
var Quiz = document.getElementById('txtQuiz').value - 0;
var WrPaper = document.getElementById('txtWP').value - 0;
var OSME = document.getElementById('txtOSME').value - 0;
//for (var i = 1; i < grdLength - 1; i++) {
var Total = parseFloat(Participation) + parseFloat(Assgnmnt) + parseFloat(Quiz) + parseFloat(WrPaper) + parseFloat(OSME);
if (!isNaN(Total)) {
document.getElementById('txtTotal').value = Total;
}
else {
alert("Nikal");
}
}
var getTotal = document.getElementById('txtTotal').value - 0;
var Gtot = parseInt(Gtot) + parseFloat(getTotal);
if (!isNaN(Gtot)) {
document.getElementById('txtGTot').value = Gtot;
}
else {
alert("Cannot Show Total");
}
var Percentage = (parseFloat(Gtot) * 100) / 400;
if (!isNaN(Percentage)) {
document.getElementById('txtPercent').value = Percentage;
}
else {
alert("Cannot show percentage");
}
}