PDA

View Full Version : How to change the visibility of a <TD>


imroue
11-11-2002, 05:25 AM
I have a code like this:

<TD STYLE=display:inline>
Blah 1
</TD>
<TD STYLE=display:inline>
Blah 2
</TD>
<TD STYLE=display:inline>
Blah 3
</TD>

Is there a way to change the display of any of these TD's with a function. It's important that I use the <TD> and not <DIV> or <p>.

Does TD have a property with a name or something... such as
the name of <a name="blah"> </a>

:)

glenngv
11-11-2002, 05:55 AM
you can't hide a TD but you can put the content in a DIV.

why don't you like this?

<td><div id="col1" style="display:inline">Blah 1</div></td>

then you can hide the content by:
document.getElementById("col1").style.display="none";

imroue
11-11-2002, 02:44 PM
Glenngv,

actually I can hide <TD> by doing this:

<TD STYLE=display:NONE>
Blah 1
</TD>

The problem I have with this:
<td><div id="col1" style="display:inline">Blah 1</div></td>

is that when I hide it, it hides everything inside the <TD>, which is ok, but I also want the <TD> itself to hide. The reason I need that to happen is because I hide many <TD>'s and even though i have set border = 0, it shows up a little space, which adds up considering how many I am hiding.:(

Thanks for your reply, but if you have any other ideas, please let me know. :)

glenngv
11-12-2002, 01:22 AM
try also putting cellpadding=0 and cellspacing=0 in the <table> tag so that the space will be a little smaller.

but still, I think, you can't totally *hide* the TD.
Maybe you can use DOM to remove/add the TD.

imroue
11-13-2002, 07:47 PM
Originally posted by glenngv
try also putting cellpadding=0 and cellspacing=0 in the <table> tag so that the space will be a little smaller.

but still, I think, you can't totally *hide* the TD.
Maybe you can use DOM to remove/add the TD.

What can I use DOM to do this?
I found a way to do this by using
<TD ID="id_name" STYLE='display:inline'>
and changing the style dynamically.

but I am curious how to use the DOM. let me know

THANKS!:thumbsup:

boggly
11-13-2002, 08:42 PM
With the DOM, You should be able to just reference the table cells by their id attributes and change their display dynamically by setting the value to "none".

Regards,
boggly