Table row color altering based on conditions

Please support our HTML and CSS advertiser: $6.99 Domain Names at 1&1. Includes Free Privacy. Save Now!
Reply

Join Date: Jul 2009
Posts: 8
Reputation: ritu_kr is an unknown quantity at this point 
Solved Threads: 0
ritu_kr's Avatar
ritu_kr ritu_kr is offline Offline
Newbie Poster

Table row color altering based on conditions

 
0
  #1
Jul 14th, 2009
How do alternate table row colours dynamically using css only? Else with javascript? Can i use them inside struts iterate tag?
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 276
Reputation: kanaku is on a distinguished road 
Solved Threads: 15
kanaku's Avatar
kanaku kanaku is offline Offline
Posting Whiz in Training

Re: Table row color altering based on conditions

 
0
  #2
Jul 14th, 2009
What do you mean by dynamically alternate row colours? Are you generating the html for the rows dynamically? If so, you'll have to dynamically indicate the class of the rows too. Example, in your css:
HTML and CSS Syntax (Toggle Plain Text)
  1. .row1 {background-color: black};
  2. .row2 {background-color: white};
Then in the script used to dynamically create the table, alternate between printing the row1 and row2 class:
HTML and CSS Syntax (Toggle Plain Text)
  1. foreach (rowelement) {
  2. if ($rowname = 'row1') $rowname = 'row2';
  3. else $rowname = 'row1';
  4. print "<tr class=$rowname>";
  5. }
If you know ASP, you can save other daniweb members from idiots like me by helping out in this forum.

Visit this thread
if your username starts with one of the following letters: B D F H J L N P R T X Y Z.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 8
Reputation: ritu_kr is an unknown quantity at this point 
Solved Threads: 0
ritu_kr's Avatar
ritu_kr ritu_kr is offline Offline
Newbie Poster

Re: Table row color altering based on conditions

 
0
  #3
Jul 14th, 2009
The rows are added dynamically.
1. No jsp is involved.
2. Server side html is used.

The code you have written are which elements?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 32
Reputation: dipak_passion is an unknown quantity at this point 
Solved Threads: 1
dipak_passion's Avatar
dipak_passion dipak_passion is offline Offline
Light Poster

Re: Table row color altering based on conditions

 
0
  #4
Jul 15th, 2009
Just use simple JavaScrip here, it will better.
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the HTML and CSS Forum


Views: 807 | Replies: 3
Thread Tools Search this Thread



Tag cloud for HTML and CSS
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC