On my webpage, I have a grid of selectable divs that are defined by rows and columns. When I select certain divs, it creates what I'll call "table Copy", a three-dimensional table.
If I select different elements, another three-dimensional table called "table Paste" is created.
The first time I select two columns and two rows, the table looks like this:
x,y - positions
at1,at2,at3 - attributes for later copy
Table Copy
1 2
0:[x,y,at1,at2,at3],[x,y,at1,at2,at3]
1:[x,y,at1,at2,at3],[x,y,at1,at2,at3]
When three columns with three rows are selected, the tables look like this:
Table Copy
1 2
0:[x,y,at1,at2,at3],[x,y,at1,at2,at3]
1:[x,y,at1,at2,at3],[x,y,at1,at2,at3]
Table Paste
1 2 3
0:[x,y,at1,at2,at3],[x,y,at1,at2,at3],[x,y,at1,at2,at3]
1:[x,y,at1,at2,at3],[x,y,at1,at2,at3],[x,y,at1,at2,at3]
2:[x,y,at1,at2,at3],[x,y,at1,at2,at3],[x,y,at1,at2,at3]
I now require a function to fill the contents of table paste with the content from table copy:
Table Paste
1 2 3
0:[tabCopy[0][1]],[tabCopy[0][2]],[tabCopy[0][1]]
1:[tabCopy[1][1]],[tabCopy[1][1]],[tabCopy[1][1]]
2:[tabCopy[0][1]],[tabCopy[0][2]],[tabCopy[0][1]]
There are various possibilities for the sizes of both arrays.
If table Copy has 4 rows and table Paste only has 3, then the fourth row of table Copy should be 'ignored'.
If table Copy has only 1 row and 1 column, all records in table Paste will be the same as well.
If table Paste has only 1 row and 1 column, it should take only the first record from table Copy.
I hope I've explained everything clearly :)
Thank you for your help!