Results 1 to 2 of 2

Thread: Table Help

  1. #1
    CoOlbOyCoOl is offline Member
    Join Date
    May 2007
    Posts
    6
    Rep Power
    0

    Default Table Help

    Hi, i need to be able to alternate colours in my table. Such that the first row is blue, the second is yellow and so on. How can i implement it into my code?
    Help will be greatly appreciated.

    Java Code:
    <&#37;@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <html>
        <head>
            <title>Count to 10 Example(using JSTL)</title>
        </head>
        <body>
            <table border = 1 name = "index">
                <c:forEach var="i" begin="1" end="5" step="1">
                    <tr>
                        <td>
                            <c:out value="${i}" />
                        </td>
                        <td>
                            <c:out value="${i*2}" />
                        </td>
                        <td>
                            <c:out value="${i*3}" />
                        </td>
                    </tr>
                </c:forEach>
            </table>        
        </body>
    </html>
    Last edited by levent; 05-06-2007 at 01:03 PM. Reason: [code] tag was missing. Added it to make the code more readable.

  2. #2
    pegitha is offline Member
    Join Date
    Apr 2007
    Location
    Indiana
    Posts
    83
    Rep Power
    0

    Default

    I can show you how I did that in struts, maybe you can conver the basic idea to your code. I defined a variable named color based on if the row number was odd or even.
    Java Code:
    <bean:define id="counter" value='<&#37;=ctr.intValue() % 2 + ""%>' />
      <logic:equal name="counter" value="0">
        <bean:define id="color" value="gray" />
      </logic:equal>
      <logic:equal name="counter" value="1">
         <bean:define id="color" value="white" />
      </logic:equal>
    This was all inside an iterator for a list that was displaying.
    then I had a stylesheet with that stye name in it such as
    .white td {background: #fff;}
    hth

Similar Threads

  1. Hash Table help
    By rhm54 in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 02:25 AM
  2. Inserting into a table (Example)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-06-2008, 10:25 AM
  3. AWT Table Scrolling
    By albert_kam in forum AWT / Swing
    Replies: 0
    Last Post: 01-03-2008, 12:37 PM
  4. regarding to creating table.....
    By daredavil82 in forum New To Java
    Replies: 0
    Last Post: 11-18-2007, 05:55 AM
  5. Help with multiplication table
    By Albert in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 05:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •