Click to See Complete Forum and Search --> : HTML Dynamic TABLE HELP


klanga2049
06-13-2006, 02:50 PM
here is a simplified example of what I want to do.

I have a table with where one row contains 2 cells.
the first one has colspan=1 and the second has colspan=2.

On some button click, I want to change the table so the first cell is gone, and the second cell gets colspan=3 (basically it takes up the room of the first cell) I want to leave the other rows unaffected.

I know a little javascript but I'm not sure how to accomplish this.
I can get the contents of cell 1 to disappear using
document.getElementById("cell1").innerHTML = '';

but i cant get it to go away. changing the colspan of cell2 to 3 does not work either because cell 1 still exists.

any help would be appreciated.

KDLA
06-13-2006, 03:06 PM
Is the table necessary? Might be easier with a div.
You could have a link that calls some javascript which looks for the element (the column) by ID and switches it to an alternate ID with "display: none;" set.

KDLA

klanga2049
06-13-2006, 03:15 PM
well, the row I want to change does not stand alone, its in the midst of a table with rows above and below.

just happens that I want to change this one.

and
document.getElementById("cell1").style="display:none";
gives me an error...

KDLA
06-13-2006, 03:31 PM
Tables aren't too functional for layout purposes.

The only other thing I can think of is to have a two part js, which
- looks for cell one, and changes the width to 0 (and gets rid of the content) via a class change
- looks for cell two (the neighboring cell, and changes the width to 100% via another class change

klanga2049
06-13-2006, 04:40 PM
doubt that would work since the other cells in that column won't be set to width=0. and width=0 does not mean the cell won't count for the colspans

kelly23
06-13-2006, 04:53 PM
Hi,

document.getElementById("cell1").style="display:none";

That should be:

document.getElementById("cell1").style.display="none";


kelly

klanga2049
06-14-2006, 10:43 AM
Kelly that worked perfectly!

thanks to all for fixing this for me

kelly23
06-14-2006, 02:05 PM
You're welcome :)