This is my table
Type Time Month
A Yes Jan
A Yes Feb
A No Mar
A Yes Apr
This is what I get in return:
Month YES NO
Jan 1 0
Feb 2 0
Mar 0 3
Apr 0 4
What I want is for my count of to look like this:
Month YES NO
Jan 1 0
Feb 1 0
Mar 0 1
Apr 1 0
Here is my script. I'm racking my head and any help is greatly appreciated. Thanks
<Script>
function processResult(xData, status) {
var Month = [];
var i = 0;
var TableRow = "<table>";
$(xData.responseXML).find("z\\:row").each(function() {
var sType = $(this).attr("ows_Title");
var sTime = $(this).attr("ows_Time");
var sMonth = $(this).attr("ows_Month");
i = i + 1;
if(Month[sMonth]==undefined)
{
Month[sMonth] = [0,0,0,0];
}
if(Month[sMonth]!=undefined)
{
if (sTime == "Yes" && sType == "A"){Month[sMonth][0] = i}
if (sTime == "No" && sType == "A"){Month[sMonth][1] = i}
}
});
var key = "";
for(key in Month){
TableRowHtml += "<TR><td style='text-align: Left'> " + key +" </td><td>" + Month[key][0] + "</td><td> "+ Month[key][1] + "</td><TR>";
}
TableRowHtml +="</Table>";
$("#tasksUL").append(TableRowHtml);
}
</Script>
Thanks