3 replies [Last post]
Pinago
Pinago's picture
Offline
Regular
Last seen: 11 years 8 weeks ago
Timezone: GMT-4
Joined: 2010-02-18
Posts: 49
Points: 66

Does anyone know the CSS or HTML (or combo) script to be able to have a table row collapse when there is no text in one cell, but there is text in the next cell? I have a 2-column table with titles in the left column and want the right column to be populated by a user. If the user doesn't populate the right cells or row, I'd like that row -including the constant/visible text that is in the left col- to be hidden and that row to collapse or move up...

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 41 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

No.

No.

However you can likely use a back-end script to do this.

The back-end script will look to see if each title has an associated value (I'm assuming these are stored in a hash somewhere?). If it doesn't, it can dynamically add to the HTML a class name on the tr containing those td's.

Your CSS can then have that class name styled with display: none I believe (I'm not certain because I don't think I've every tried display: none in a table row before, and tables can be squirrely when it comes to display).

There is no way for HTML and CSS to look at the content themselves, which is why this will have to be a back-end script. I can think of some kind of convoluted possibility with CSS for making the second td determine total tr height but it would be certain to break in most browsers.

I'm no expert, but I fake one on teh Internets

Pinago
Pinago's picture
Offline
Regular
Last seen: 11 years 8 weeks ago
Timezone: GMT-4
Joined: 2010-02-18
Posts: 49
Points: 66

Javascript?

Thanks. So, a javascript perhaps? I would think this function could be found online somewhere, but because it's such a specific question I can't seem to find it on Tables how-to sites or in general searches...

Stomme poes
Stomme poes's picture
Offline
Elder
Netherlands
Last seen: 10 years 41 weeks ago
Netherlands
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

There should be some

There should be some Javascript out there that does this:

look for "shows hides table rows", or "collapses table rows" or "displays table rows" with "javascript" in the query. Or any of those sites showing how to sort tables should also have something for show-hide table rows as well.

I'm no expert, but I fake one on teh Internets