Want to change color on click!?

Reply

Join Date: Dec 2004
Posts: 2
Reputation: vcombs is an unknown quantity at this point 
Solved Threads: 0
vcombs vcombs is offline Offline
Newbie Poster

Want to change color on click!?

 
0
  #1
Dec 29th, 2004
I am displaying data in a table on one of my web pages. When the user clicks on a row, I want that row ONLY to change color. I'd settle for that cell. I have a css file referenced on the page with two styles, td_on and td_off, which have same settings except for the background colors. I put the "class" tag in the td like so: <td align="center" class="td_off" >

I have tried to use the onclick action to change the class to the td_on style like so, onclick="class=td_on" but this does NOT cause any changes. Can someone tell me what the proper syntax for doing this is ... or maybe an easier way to accomplish what I want???!

TIA
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 33
Reputation: pajac is an unknown quantity at this point 
Solved Threads: 0
pajac's Avatar
pajac pajac is offline Offline
Light Poster

Re: Want to change color on click!?

 
0
  #2
Jan 23rd, 2005
Maybe u could try onclick="id='td_off'" . I'm not exacly shure if it is the write sintax, maybe it has to be something infront of " style='td_of' ", like TD or something. But I think this works.I'm new here to!
Try and reply!

Ok I tried it myselfe and the only problem is vith IE couse u have to alow a "popup" if u wont it to work.
Firefox goes OK! :o
Last edited by pajac; Jan 23rd, 2005 at 11:58 am. Reason: I'm stupid!!
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 33
Reputation: pajac is an unknown quantity at this point 
Solved Threads: 0
pajac's Avatar
pajac pajac is offline Offline
Light Poster

Re: Want to change color on click!?

 
0
  #3
Jan 23rd, 2005
Use ID instead of class in css.

dont .something but #something ok.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 62
Reputation: 2ndPlatform is an unknown quantity at this point 
Solved Threads: 0
2ndPlatform's Avatar
2ndPlatform 2ndPlatform is offline Offline
Junior Poster in Training

Re: Want to change color on click!?

 
0
  #4
Jan 24th, 2005
Originally Posted by vcombs
I am displaying data in a table on one of my web pages. When the user clicks on a row, I want that row ONLY to change color. I'd settle for that cell. I have a css file referenced on the page with two styles, td_on and td_off, which have same settings except for the background colors. I put the "class" tag in the td like so: <td align="center" class="td_off" >

I have tried to use the onclick action to change the class to the td_on style like so, onclick="class=td_on" but this does NOT cause any changes. Can someone tell me what the proper syntax for doing this is ... or maybe an easier way to accomplish what I want???!

TIA
Here - if you haven't gotten it, try this:

This should be your TD in your HTML:

HTML and CSS Syntax (Toggle Plain Text)
  1. <td class="out" onMouseOver="this.className='over'" onMouseOut="this.className='out'"><a href="page.php">LINK</a></td>

Then in your stylesheet:

HTML and CSS Syntax (Toggle Plain Text)
  1. .over { background-color:#D0C0A9; padding-top: 2px; padding-bottom:2px;}
  2. .out { background-color: #E1D4C0; padding-top: 2px; padding-bottom:2px;}

That should do it for ya!

Let me know if you have problems, I'd be glad to help.

Shannon
Second Platform
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 33
Reputation: pajac is an unknown quantity at this point 
Solved Threads: 0
pajac's Avatar
pajac pajac is offline Offline
Light Poster

Re: Want to change color on click!?

 
0
  #5
Jan 24th, 2005
God solution 2ndPlatform!
I'm missing some experiences at this field, but doing on that too. :mrgreen:
::: Ha thisone nobody has! :lol: :lol:
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 1
Reputation: billbob12345678 is an unknown quantity at this point 
Solved Threads: 0
billbob12345678 billbob12345678 is offline Offline
Newbie Poster

Re: Want to change color on click!?

 
0
  #6
Apr 27th, 2009
Originally Posted by vcombs View Post
I am displaying data in a table on one of my web pages. When the user clicks on a row, I want that row ONLY to change color. I'd settle for that cell. I have a css file referenced on the page with two styles, td_on and td_off, which have same settings except for the background colors. I put the "class" tag in the td like so: <td align="center" class="td_off" >

I have tried to use the onclick action to change the class to the td_on style like so, onclick="class=td_on" but this does NOT cause any changes. Can someone tell me what the proper syntax for doing this is ... or maybe an easier way to accomplish what I want???!

TIA
ok so here is what i used. i got the same situation you did. kinda. anyway if your just changing the background of a cell onClick do this <td onClick="this.bgcolor='000000'"> and for rows this <tr onClick="this.bgcolor='000000'"> now obviously you can change the colors as needed or desired but this worked for me.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 3
Reputation: MasonShew is an unknown quantity at this point 
Solved Threads: 0
MasonShew MasonShew is offline Offline
Newbie Poster

Re: Want to change color on click!?

 
0
  #7
Apr 29th, 2009
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC