I have Data like This
Data:
EMPID   MONTHNAME   ABSENTDAYS  DAYSWORKED  PRESENTDAYS PENALTY
10001   January     0           1           1           100
10001   January     0           1           1           100
10001   February    0           1           1           100
10001   February    0           1           1           100
10001   February    0           1           1           100
10001   March       0           1           1           100
10001   April       0           1           1           100
10001   April       0           1           1           100
This is my Code
Code
        var html;
        var totalWorkedDays = 0;
        var totalAbsentDays = 0;
        var totalPresentDays = 0;
        var totalPenalty= 0;
        $(data).each(function (index, th) {
            if (th.MONTHNAME == 'January') {
                count = count + 1;
                totalWorkedDays = totalWorkedDays + parseFloat(th.DAYSWORKED);
                totalAbsentDays = totalAbsentDays + parseFloat(th.ABSENTDAYS);
                totalPresentDays = totalPresentDays + parseFloat(th.ABSENTDAYS);
                totalPenalty= totalPenalty+ parseFloat(th.RATE);
                html = '<td class="text-center" id=jan_' + th.SeqID + '>' + th.MONTHNAME + '</td>'
                + '<td class="text-center">' + totalWorkedDays + '</td>'
                + '<td class="text-center">' + totalAbsentDays + '</td>'
                + '<td class="text-center">' + totalPresentDays + '</td>'
                + '<td class="text-center">' + totalPenalty.toFixed(2) + '</td>'
                + '</tr>';
            }
            if (th.MONTHNAME == 'February') {
                count = count + 1;
                totalWorkedDays = totalWorkedDays + parseFloat(th.DAYSWORKED);
                totalAbsentDays = totalAbsentDays + parseFloat(th.ABSENTDAYS);
                totalPresentDays = totalPresentDays + parseFloat(th.ABSENTDAYS);
                totalPenalty= totalPenalty+ parseFloat(th.RATE);
                html = '<td class="text-center" id=jan_' + th.SeqID + '>' + th.MONTHNAME + '</td>'
                + '<td class="text-center">' + totalWorkedDays + '</td>'
                + '<td class="text-center">' + totalAbsentDays + '</td>'
                + '<td class="text-center">' + totalPresentDays + '</td>'
                + '<td class="text-center">' + totalPenalty.toFixed(2) + '</td>'
                + '</tr>';
            }
        });
        fa_table.append(html);
Result:
Month     TotalAbsent    TotalWorked    TotalPresent    TotalPenalty
February  0              3              3               300.00
The month of January is not showing... i want to show all of the months dynamically with total below.
please help. Thanks in Advance..
 
    