Click to See Complete Forum and Search --> : Alternating Colors on a Discussion Board


jndale
03-16-2005, 02:07 PM
I just posted on the HTML board and they told me to post to this board. Here is my problem:

:confused: :confused: :confused: :confused: :confused: :confused:

I have a discussion board and I need to have the colors alternate between the messages but I have a couple of problems.

[list=1]
It is a .css driven site

Each message is on two rows: 1 row for subject, name, & date and 1 row for the message itself.

I am being completely brain dead and cannot think this out for the life of me.
[/list=1]

I'm pretty sure it is a simple if, else statement or something like that but my brain is not wrapping around this. If anyone has any suggestions at all please let me know. I have wasted so much time on this and I am on a VERY short deadline with 50 other things to do as well. Any help would be GREATLY appreciated!

Thanks to all!!

Jamie

Note: It is a jsp. That's the problem I'm having. I've found code for ASP & PHP but not HTML or JSP.

buntine
03-16-2005, 07:54 PM
Create another CSS item/class with the other background color. You might have something like this:

bg_white
{
}

bg_grey
{
}

Then, in your JSP there will be a loop to iterate through each post. In there place an if statement like this:

strBackColor = (strBackColor.equals("bg_white")) ? "bg_grey" : "bg_white";

Place the preceing line at the top of the loop. And don't forget to declare it (String strBackColor = new String()) above the loop.

At the moment, the CSS class is probably stated explicitely. Just alter it so it prints the variable value instead. eg <table ... class="<%= strBackColor %>">

Note, obviously, you have to change the bg_white and other items to conform to your nameing conventions, etc.

Regards.

jndale
03-18-2005, 07:03 AM
Thanks! This will help a bunch!