Possible Duplicates:
How to alternate HTML table row colors using JSP?
Table row - Giving alternate colors
can any one provide basic code for dynamically adding rows in a table with alternate colors using css in jsp file kindly provide this code
Possible Duplicates:
How to alternate HTML table row colors using JSP?
Table row - Giving alternate colors
can any one provide basic code for dynamically adding rows in a table with alternate colors using css in jsp file kindly provide this code
Basically, there are two options:
<table>
<?
boolean evenRow = true;
for (int i = 0; i < numRowsToDisplay; i++)
{
?>
<tr class="<?= evenRow? "evenrowstyle" : "oddrowstyle" ?>"><td>whatever</td></tr>
<?
evenRow = !evenRow;
}
?>
</table>
as in
<style>
#TableID tr:nt-child(odd){
background-color:white;
}
#TableID tr:nth-child(even){
background-color:silver;
}
</style>