3

I have an HTML table of data and I want to mimic the Excel Color scales for conditional formatting so it highlights the relative value across this set of data.

The HTML table is simply drawing out a list of rows and for each row I have a value ( 0 - 300) and i want to have it color the background of the row of the table based on this algorithm so I assume it will need to generate an HTML color name or value for each number that is input

Any help where to start here?

pnuts
  • 58,317
  • 11
  • 87
  • 139
leora
  • 188,729
  • 360
  • 878
  • 1,366

1 Answers1

1

You could use this, and when deciding to generate the color, divide the row value/300 to use the exact function.

Edit (Originally a comment)

When specifying html colors, you can use the rgb(Rvalue, Gvalue, Bvalue) notation. Or you could convert the decimal values to their hex equivalent to to the #RRGGBB notation.

In javascript, this would be achieved by following this method to convert to hex

Community
  • 1
  • 1
Ahmad
  • 22,657
  • 9
  • 52
  • 84
  • i dont understand. how would i then convert this to HTML colors ?? – leora Dec 09 '10 at 22:36
  • how can you convert to the #RRGGBB notation ? – leora Dec 10 '10 at 04:24
  • @ooo - once you have the hex values for the colors, you concatentate the results to produce a color `var col = '#' + rHex + ghex + bHex` and then jquery this fella to the correct table row – Ahmad Dec 10 '10 at 04:43