Date:  11/15/2006 05:55:33 PM Msg ID:  003217
From:  FoxWeb Support Thread:  003209
Subject:  Re: How to display grids in alternative colo
You can set the background color individually for each cell, but a much better solution is to create two classes with different styles.  Your code will need to assign the right class to each row:
 
<html>
<head>
<style>
.OddRow {background-color: yellow}
.EvenRow {background-color: white}
</style>
</head>
<body>
<table>
<%
M.RecCount = 1
SCAN
%>
<tr class="<%=IIF(M.RecCount % 2 = 0, 'EvenRow', 'OddRow')%>">
<td><%=FirstName%></td>
<td><%=LastName%></td>
</tr>
<%
M.RecCount = M.RecCount + 1
ENDSCAN
%>
</table>
</body>
</html>
 
In the above code, M.RecCount % 2 will return 0 for even rows and 1 for odd rows.  The resulting HTML code will look something like this:
<html>
<head>
<style>
.OddRow {background-color: yellow}
.EvenRow {background-color: white}
</style>
</head>
<body>
<table>
<tr class="OddRow">
<td>John</td>
<td>Jensen</td>
</tr>
<tr class="EvenRow">
<td>Mike</td>
<td>Eakins</td>
</tr>
<tr class="OddRow">
<td>Moses</td>
<td>McBeal</td>
</tr>
<tr class="EvenRow">
<td>Andrew</td>
<td>Pope</td>
</tr>
</table>
</body>
</html>

FoxWeb Support Team
support@foxweb.com email

Sent by Larry Zhang on 11/13/2006 08:29:25 AM:
Thank you for your reply.
 
What I want to achieve is to have different background color for each row of records. Now every line is white. I wish to display them as white, yellow, white , yellow, alternatively.
 
Using your code, every line will be yellow.  Thanks again.
 
 
Sent by FoxWeb Support on 11/13/2006 07:06:55 AM:
Please try to be more specific in your questions. What do you mean by "grids"? Are you referring to HTML tables? Also, which color are you trying to change, the cell background color, the text color of the content, or the border color? I will assume that you are indeed referring to HTML tables. You can change all three colors above using regular HTML code, like this:
 
<table bordercolor="blue">
    <tr>
        <td bgcolor="yellow"><font color="red">Hello!</font></td>
    </tr>
</table>
 
However, a much better technique is to use cascading stylesheets (CSS). For information on CSS you will need to consult an appropriate book, or on line reference.

FoxWeb Support Team
support@foxweb.com email

Sent by Larry Zhang on 11/10/2006 08:25:41 AM:
How to display grids in alternative colors?
 
Funny the subject field above is too short and can not hold so many characters.
 
It might be a HTML question. I do appreciate it if anyone can give an answer.  Thanks.