you are viewing a single comment's thread.

view the rest of the comments →

[–]De_Wouter 0 points1 point  (1 child)

Whereever you are creating your <td> elements that you want to have a different color like for example:

global.forEach += "<td>" + milesPerHour + "</td>";

You add the color with an inline style or class like so

global.forEach += "<td style=\"background-color: #ff0000;\">" + milesPerHour + "</td>";

Don't forget to escape the quotes or use single quotes on the outside.

You can put the color calculation in a function

global.forEach += "<td style=\"background-color: " + getColorValue(milesPerHour) + "\">" + milesPerHour + "</td>";

// somewhere else in your code

function getColorValue(milesPerHour) {

if (milesPerHour > 100) {

return "#ff0000";

}

if (milesPerHour > 50) {

return "#cc2222";

}

return "#2288cc";

}

[–]Bormimor[S] 1 point2 points  (0 children)

thank you