Here's what I have, but it's not working properly:
var divTitleIds = new Array("#TKITitle", "#bugsTitle","#engTitle","#tEngTitle","#attTitle","#gtsTitle","#goalsTitle","#RISTitle","#RplSTTitle","#agileTitle",
"#availTitle", "#scalTitle", "#perfTitle", "#tCostTitle", "#BIRTitle", "#TTMTitle", "#CTTitle", "#edwatbTitle", "#edwbatchTitle", "#edwbatchTitle", "#mrtzTitle");
summaryColors("#summaryTitle", divTitleIds);
function summaryColors(div, arrayOfDivs) {
var green = 0; var yellow = 0; var red = 0; var grey = 0;
for (var i = 0; i < arrayOfDivs.length; i++) {
if ($(arrayOfDivs[i]).css('background-color') == 'rgb(52,128,23)')
green++;
else if ($(arrayOfDivs[i]).css('background-color') == 'rgb(255,227,3)')
yellow++;
else if ($(arrayOfDivs[i]).css('background-color') == 'rgb(228,34,23)')
red++;
else
grey++;
}
if (green / arrayOfDivs.length > .75)
$(div).css('background-color', '#348017'); //green
else if (green / arrayOfDivs.length > .25 && red / arrayOfDivs.length < .33)
$(div).css('background-color', '#FFE303'); //yellow
else
$(div).css('background-color', '#E42217'); //red
}
the code is saying they are all gray (the first else statement) and therefore returning a red background for div (the last else statement).
the rgb values in the forloop correspond to the # values in the second set of checks. I tried using the #values both places and that didn't work either.

New Topic/Question
Reply


MultiQuote




|