On Dec 5, 2005, at 2:59 PM, dbdweeb wrote:

Is there some sample code on how to render alternating background
colors on a table row?

You could do something like this (untested):

function styledTable(styles, rows) {
    var styleIter = cycle(styles);

    var table_row = function(row) {
        return TR({style: styleIter.next()},
            map(partial(TD, null), row));
    };

    return TABLE(null,
        THEAD(null, TR(null, TD())),
        TFOOT(null, TR(null, TD())),
        TBODY(null, map(table_row, rows))
    );
};

var rows = [
    [1, 2, 3, 4],
    [5, 6, 7, 8]
];
var normalStyle = {backgroundColor: "white"};
var altStyle = {backgroundColor: "lightgrey"};
// writeln(styledTable([normalStyle, altStyle], rows);

Reply via email to