#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Utah
    Posts
    20
    Rep Power
    0

    Alternating table row colors


    Ive searched here and several other sites to find an example of how to display alternating table row colors. I've had no luck, so I thought I would ask.
    I have a bean that selects an array of records from a DB. I want to display those records in my .jsp file in list of table rows with alternating colors.

    Can anyone point me to any examples of how others have done this?
    Thanks,
    iDezzign
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Location
    Utah
    Posts
    20
    Rep Power
    0
    Nevermind... I got it. A co-worker had the answer. Just incase youre wondering.

    Code:
    String cssClassname = "#cccccc";
                              while(it.hasNext()) { 
                                campName = it.next().toString(); 
    						
    							if (counter % 2 != 0){ 
    								cssClassname = "white";
    							} else { 
    								cssClassname = "#cccccc"; 
    							}
    							counter++;
    
                                out.println("\n<tr bgcolor=\"" + cssClassname + "\" class=\"" + cssClassname + "\"><td>" + counter + "|" + campName + "</td></tr>");
                                
                              }

IMN logo majestic logo threadwatch logo seochat tools logo