wood burning stoves 2.0
The moose likes HTML, CSS and JavaScript and the fly likes CSS combined names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "CSS combined names" Watch "CSS combined names" New topic

CSS combined names

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I downloaded some code with CSS involved, when a table cell is clicked, the corresonding row and column are highlighted. the way to highlight is defined in CSS, suppose row highlight is assigned with classname: 'rowL' and column highlight is assigned with classname: 'colL'.

The intersection is defined as .rowL .colL {....}, so in the JavaScript, it highlights a row first (using row classname), then use a loop to highlight the column (using column classname), then the intersection table cell has two attributes at the same time.

I want to use CSS classname to determine the table cell value, but I have no idea to write if statement, I tried

if(cellattr.className == 'rowL' && cellattr.className == 'colL' )
if(cellattr.className == 'rowL && colL')

But none of them works.

Please help. Thanks.

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I tried if(cellattr.className == 'rowL colL')
it still does not work.
I found rowL is the row classname and colL is the column classname. When I use getElementsByTagName('TD'); I can only print classname for the columns, when I use getElementsByTagName('TR'); I only print out classname for the rows.

How could I do to found table cell classname belongs to .rowL .colL {....} ? Someone please help.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Did you consider looking at cellattr.className to see what its value actually was?
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
The class name is set to the TR and the TD seperately so of course when you read the TD it is only the one class. You would have to read the row and then the cell to get the combined className.

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I loop through TR first, then loop each TD in each row, then it works.
Thanks, guys.
I agree. Here's the link: http://aspose.com/file-tools
subject: CSS combined names
It's not a secret anymore!