Meni
-
Posts
1 -
Joined
-
Last visited
Never
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.
two CSS Zebra table created from loop
in CSS Help
Posted
I have a loop that creates a table from mysql data:
[code]echo '<table border="1" bordercolor="#CFCFCF" align="center">';// a new table for every user...[/code]
I have a javascript function that turns this table into a striped table:
[code]<script language="javascript"><!--
function zebraTable() {
// get the table
var t = document.getElementById('zebra');
// set the class name
var theClass = "evenRow";
// get a collection of rows
var rCol = t.rows;
// declare the counter
var rowNum = 0;
// loop through each row
for (var i = 0; i < rCol.length; i++) {
// apply the class name
if (i % 2 == 0) rCol[i].className = theClass;
}
}
onload = zebraTable;
--></script>[/code]
This javascrpit will inspect the ID of the table and if it's "zebra" it will stripe it.
All is well untill i want to have two or more tables in one page.
I can't name all of them "zebra" because it will only stripe the first table.
How do i go around this?