Results 1 to 2 of 2

Thread: Table Help

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

    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="" prefix="c" %>
            <title>Count to 10 Example(using JSTL)</title>
            <table border = 1 name = "index">
                <c:forEach var="i" begin="1" end="5" step="1">
                            <c:out value="${i}" />
                            <c:out value="${i*2}" />
                            <c:out value="${i*3}" />
    Last edited by levent; 05-06-2007 at 12: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
    Rep Power


    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 name="counter" value="1">
         <bean:define id="color" value="white" />
    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;}

Similar Threads

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