The short story is that I'm looking for a way to dynamically render colors within discrete cells of an HTML table.

More detail: I'm modifying some code I inherited and know enough Javascript to make myself dangerous. The page uses VBScript (which I don't know at all and I merely add here for sake of completeness) to pull SQL server data that represents blocks of data. An HTML table is used to display those blocks of data numerically, one block per row. The number of rows is dynamic, depending upon the data.

I needed to add graphic visualization of these same blocks of data within this same page. So I'm using Walter Zorn's Javascript VectorGraphics library ( to render each data block in visually representative colors and positions. This library requires rendering either directly to the doc or to a named ID used as a canvas. So I set up a DIV and am successfully applying colors stored in a Javascript array to render the colored blocks. So far so good. Now....

The problem is that, for each data block, I also need to display the analogous array color somehow in each HTML row where the numeric version is displayed—a color key that tells the eye what numeric data row goes with various color block representations. For sake of simplicity, it can just be a color swatch that takes for the form of the cell background color or a CSS style background color. From what I can tell, neither HTML or CSS supports the variable structure needed to do this... so I'm assuming that Javascript is the way to go. I'm certainly open to other suggestions. In theory, I can use the jsgraphics.js functions to do this... which would require dynamically defining a unique div name for the cell in question in each HTML row... but I can't figure out a good way to do that. I've tried adapting some posts employing the combo of document.createElement and document.body.appendChild but 1) I've had no luck and 2) ideally I need to have this div appear in place in each HTML row rather than at the end of the doc.

I'm open to any approach (although I don't know any other languages.) I suppose a completely different alternative is blowing off the HTML table and presenting the data completely via Javascript and CSS, but I still need a way to dynamically change the colors.

Thanks so much!