Modify Table Row Span!!!

A

adam_a_knight

Hi everyone,

Just working on a problem hope someone can help.
I have created a function to modify table elements and have had some
success with merging columns left and right.
However, i can't seem to merge row columns below or above. It works
for the first couple of times then gives a message that the object to
be merged doesn't exist

I know it is because the underlining table structure is changing..but
not sure how to get around it.

HTML AREA 3 does it also..

Thanks
AJ
function getRowSpan(selectedCell,mergeCell)
{
var currentSpan = (!selectedCell.rowSpan)? 1 : selectedCell.rowSpan;
var mergeSpan = (!mergeCell.rowSpan)? 1 : mergeCell.rowSpan;
\\can't find merge cell after a couple of columns have had their
rows merged.
var rowSpan = currentSpan + mergeSpan;
return rowSpan;
}

function mergeTableCells(mergeVal,range)
{
var obj = range.parentElement();
switch (mergeVal)
{

case "below":
//add row span of columns/row.
obj.parentNode.childNodes[obj.cellIndex].rowSpan =
getRowSpan(
obj.parentNode.cells[obj.cellIndex],
obj.parentNode.nextSibling.cells [obj.cellIndex]);

//delete column at same cell index in row below.
obj.parentNode.nextSibling.removeChild(
obj.parentNode.nextSibling.childNodes[obj.cellIndex]);
break;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top