File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Overriding CSS styles using JS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Overriding CSS styles using JS" Watch "Overriding CSS styles using JS" New topic
Author

Overriding CSS styles using JS

Karthik Mohan
Greenhorn

Joined: Sep 29, 2004
Posts: 23
I have a table for which its width, background color etc., are defined using CSS styles and applied using the <div> tag.

There is a checkbox in one of the columns and upon clicking the checkbox I would like to change the color of the selected/unselected ROW in the table. I am not able to override the initial styles specified using CSS. how can i do this ?? If i do not apply the table styles using CSS, I am able to change the color depending on the checkbox state, but when the styles are applied, there is no effect.

TIA
karthik
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Without seeing the code, I have a feeling you are styling the cells with a background color and changing the row? Am I right?

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

"Karthik M",

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Karthik Mohan
Greenhorn

Joined: Sep 29, 2004
Posts: 23
Eric, my JS function is



I call the JS function like



where matInd_1_1 is the "id" for that table row ..

[double quotes are omitted due to errors while posting .. the spaces for the onclick event also for similar reasons]

thanks
karthik

[ August 08, 2005: Message edited by: Karthik M ]
[ August 08, 2005: Message edited by: Karthik M ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Karthik Mohan
Greenhorn

Joined: Sep 29, 2004
Posts: 23
That does not solve the problem. The table row's color is not changing at all.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I just wrote you a fancy version of a script that changes the row color depending on the checkbox.



Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding CSS styles using JS
 
Similar Threads
Need help with TOMAHAWK Calendar t:inputCalendar
Adding css to display tag
Changing background color
what is the use of class attribute associated with a HTML element.
CSS Specificity