Alternate Colors in Table in a Database Activity

In order to create a table with alternating row colors in a database activity:

The following code goes into the javascript template:

function highlightRows() { var myTables=document.getElementsByTagName('table'); var myRows = []; for (var i=0;i<myTables.length;i++){ if (myTables[i].getAttribute('name')=='listviewrow'){ myRows.push(myTables[i]); } } for (var i=0;i<myRows.length;i++){ myRows[i].className = 'd'+(i%2); } };

Then in the list view, you should switch to html mode and add to the table tag in the repeated entry section the following clause:


and you need to add in the list footer section the following code:

<script type="text/javascript">highlightRows();</script>

Finally modify the css definitions in the css template to:

table.d0 td { background-color: #FFFFFF; color: Black; } table.d1 td { background-color: #F5F5DC; color: Black; }

Color refers to the text color.