Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Re: How to provide Color banding for table rows


Message #1 by "Brett Harrington" <brett@i...> on Sun, 1 Jul 2001 03:30:57
Hi,

hope this will help



String[] alternatingColors = {"#f3f6ec", "#ffffff"};

int i = 0;



   :

   :

inside your change your <tr> to the following



while (rs.next()) { 

   :

   :



<tr bgcolor=<%=alternatingColors[i % 2] %>>



   :

   :



i++;



   :

   :





}



Good luck

Sidi

-----Original Message-----

From: "Joy Lamb" <Joy.Lamb@C...>

Date: Sat, 23 Jun 2001 19:29:30

To: "Pro_JavaServer_Pages" <pro_jsp@p...>

Subject: [pro_jsp] How to provide Color banding for table rows





> I need to be able to display the rows returned from the database in
> alternate colors for readability.  

> 

> Below is the code for the table I am displaying.  Thanks for the help.

> 

> <TABLE width = 100% border ="1" cellpadding ="1" class="clsDataTable">

>   <tr>

>     <td class="clsDataDisplayTitleTD" colspan="9">

>       SysPrin sorted by Prefix

>     </td>

>   </tr>

>   <tr>

>     <th class="clsDataDisplayTH">ID</th>

>     <th class="clsDataDisplayTH">Prefix</th>

>     <th class="clsDataDisplayTH">System Number</th>

>     <th class="clsDataDisplayTH">Prin</th>

>     <th class="clsDataDisplayTH">Card Type</th>

>     <th class="clsDataDisplayTH">Origin</th>

>     <th class="clsDataDisplayTH">Sub Product</th>

>     <th class="clsDataDisplayTH">Sub Sub Product</th>

>     <th class="clsDataDisplayTH">Agent Bank</th>

>   </tr>

> 

>    <%

> ResultSet rs = dbHandler.execSQL("select sys_prin_id, prefix, system_number, prin, card_type, origin, 

> sub_product, sub_sub_product, agent_bank from lambj.sys_prin" +

>                                   " order by prefix");

> 	{

> 

>               while (rs.next()) {

>                         String one = rs.getString("Prefix");

>                         String two = rs.getString("system_number");

>                         String three = rs.getString("prin");

>                         String four = rs.getString("card_type");

>                         String five = rs.getString("origin");

>                         String six = rs.getString("sub_product");

>                         String seven = rs.getString("sub_sub_product");

>                         String eight = rs.getString("agent_bank");

>                         String nine = rs.getString("sys_prin_id");

> 

>       %>

> 

>   <tr>

>     <td size="10%" align="center" class="clsDataText"><%=nine%></td>

>     <td size="10%" align="center" class="clsDataText"><%=one%></td>

>     <td size="30%" align="center" class="clsDataText"><%=two%></td>

>     <td size="10%" align="center" class="clsDataText"><%=three%></td>

>     <td size="10%" align="center" class="clsDataText"><%=four%></td>

>     <td size="10%" align="center" class="clsDataText"><%=five%></td>

>     <td size="10%" align="center" class="clsDataText"><%=six%></td>

>     <td size="10%" align="center" class="clsDataText"><%=seven%></td>

>     <td size="10%" align="center" class="clsDataText"><%=eight%></td>

> 

>   </tr>

>   <%

> 

>    }

> rs.close();

>  }

> 

> %>

> </table>

> 






  Return to Index