I like to use style classes -- but it would use the same technique, but it
keeps the colors definitions out of the HTML:
<style>
.row0 { background-color: 55FFFF }
.row1 { background-color: 5555FF }
</style>
... then ...
 <tr class="row<%= index %>">

This technique also works if you want to rotate between more than two
colors.

but I usually use a MOD function (% operator) to turn the rowcount into a 0
or 1. 

-----Original Message-----
From: Thomas F�rster [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 10, 2001 2:16 AM
To: [EMAIL PROTECTED]
Subject: Re: [DBTags]: Displaying ResultSet in HTML-table with
alternating row-colors


Thomas F�rster wrote:
[...]
 
> The question is, how do I get <sql:rowCount/> into the int-variable?
> Or is there a better way to get multicolored tables?

A second after I sent my previous mail I found the solution. It's much
easier
than I thought:

[...]
  <% String colors[] = { "#55ffff", "#5555ff" }; 
     int index = 0;
  %>
  <sql:resultSet id="rset2">

    <tr bgcolor="<%=colors[index]%>">
      <td><sql:getColumn position="1"/></td>
      <td><sql:getColumn position="2"/>
          <sql:wasNull>[no description]</sql:wasNull>
      </td>
    </tr>
    <% index ^= 1; %>
  </sql:resultSet>


Thomas

Reply via email to