Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding CSS styles using JS

 
Karthik Mohan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Karthik Mohan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Karthik Mohan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That does not solve the problem. The table row's color is not changing at all.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just wrote you a fancy version of a script that changes the row color depending on the checkbox.



Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic