July 15th, 2003, 05:26 PM
-
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
July 15th, 2003, 05:54 PM
-
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>");
}