miregistered
Technical User
Hello,
I found the following script on the net:
<script type="text/javascript">
function alternate(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
//manipulate rows
if(i % 2 == 0){
rows.className = "even";
}else{
rows.className = "odd";
}
}
}
}
</script>
<body onload="alternate('table1')">
It works fine but if the table with id="table1" appears once in the code. If it appears more than once it works only for the first one.
How could I modify it to work for more than one table?
Thanks in advance, D.
I found the following script on the net:
<script type="text/javascript">
function alternate(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
//manipulate rows
if(i % 2 == 0){
rows.className = "even";
}else{
rows.className = "odd";
}
}
}
}
</script>
<body onload="alternate('table1')">
It works fine but if the table with id="table1" appears once in the code. If it appears more than once it works only for the first one.
How could I modify it to work for more than one table?
Thanks in advance, D.