I found a script to change the color of every seccond row to make it look nice, but when i add another table on the same page it colours the first table but the seccond table gets no colour why is this??
code of table.js
jQuery(document).ready(function() {
//for tables style
function altRows(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
if(i % 2 == 0){
rows[i].className = "evenrowcolor";
}else{
rows[i].className = "oddrowcolor";
}
}
}
}
window.onload=function(){
altRows('alternatecolor');
}
});
php webpage code:
<?php
//first table
echo'
<table class="altrowstable" id="alternatecolor">
<tr>
<th>Seller</th>
<th>price(per 1k doge)</th>
<th>payment allowed</th>
<th>View Trade</th>
</tr>
<td>Example</td>
<td>Example</td>
<td>Example</td>
</tr>';
echo'</table> <br />';
//seccond table
echo '<h3>trades on going </h3>';
echo ' <table class="gridtable">
<table class="altrowstable" id="alternatecolor">
<tr>
<th>Trade User</th>
<th>Cost($)</th>
</tr>
<td>Example</td>
<td>Example</td>
<td>Example</td>
</tr>';
echo'</table> ';
?>