Q:

javascript pass table data to php script

I have a table (that can be fairly large....say 200x200 px) where each cell has a background color, and a small image in it. The user will be able to click the cell and change the color/symbol (the symbol represents the color), via jQuery/Javascript. How can I pass the table data to a PHP script so it can be assembled into an image or pdf?

A:

var output = [],
    row    = 0;
$('table').find('tr').each(function (index, obj) {
    output.push([]);
    var TDs = $(this).children();
    $.each(TDs, function (i, o) {
        output[row].push($(this).css('background-color'));
    });
    row++;
});

Here is a demo: http://jsfiddle.net/y8NwV/
This will iterate through each TD element in your table, get it's background color, and then add that data to a two dimensional array.

