paygo
asked on
JSTL Create Alternating Table Row / Cell Background colors using odd and even % row calculations
Hi Everyone. I'm just trying to create alternate / alternating background colors for my list tables
using JSTL. The varStatus.count field does show 1...2...3...4...5 (array occurs if quuerried) so this the input object is OK.
There must be something else missing. Thanks
1) First - Here's the css for the 2 table background color properties:
<STYLE TYPE="text/css">
<!--
.colorBlue
{
background-color:#FFF8EE;
}
.colorWhite
{
background-color:#FFFFFF;
color:white;
}
-->
</STYLE>
Here's the JSTL that should change with the alternating rows.
<c:forEach var="item" items="${sessionScope.AVal idArray}" varStatus="status">
<c:set var="cellColor">
<c:choose>
<c:when test="${status.count % 2 == 0}">colorBlue</c:when>
<c:otherwise>colorWhite</c :otherwise >
</c:choose>
</c:set>
<TABLE class="cellColor">
<TR><TD>the table colors should alternate with each outoput row</TD></TR>
<TABLE>
</c:forEach>
Note: When I <c:out value="${status.count}"/> I do get 1...2...3...4...5..6..7..8 ..9..10... etc
Either the 'whenTest' or the 'cellColor' set up that is not working ? ? ? ?
using JSTL. The varStatus.count field does show 1...2...3...4...5 (array occurs if quuerried) so this the input object is OK.
There must be something else missing. Thanks
1) First - Here's the css for the 2 table background color properties:
<STYLE TYPE="text/css">
<!--
.colorBlue
{
background-color:#FFF8EE;
}
.colorWhite
{
background-color:#FFFFFF;
color:white;
}
-->
</STYLE>
Here's the JSTL that should change with the alternating rows.
<c:forEach var="item" items="${sessionScope.AVal
<c:set var="cellColor">
<c:choose>
<c:when test="${status.count % 2 == 0}">colorBlue</c:when>
<c:otherwise>colorWhite</c
</c:choose>
</c:set>
<TABLE class="cellColor">
<TR><TD>the table colors should alternate with each outoput row</TD></TR>
<TABLE>
</c:forEach>
Note: When I <c:out value="${status.count}"/> I do get 1...2...3...4...5..6..7..8
Either the 'whenTest' or the 'cellColor' set up that is not working ? ? ? ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.