Ho una tabella così definita:
<table border="1" width="100%"
class="righealterne" id="tabella1">
All'evento onload applico l'effetto delle righe alterne, e funziona.
Però se applico l'effetto righello(al passaggio del mouse si colora la riga e al clik c'è il link) dà l'errore
Error: document.getElementById(IDtabella) has no properties
nella prima linea di codice della funzione...perchèèèè????
Thxxxx
<script>
onload=Righello("tabella1")
function ColoraRighe(){
var tabelle=document.getElementsByTagName("table");
alert("tabelle= " + tabelle);
for(i=0;i<tabelle.length;i++){
if(tabelle[i].className.indexOf("righealterne")>=0){
trs=tabelle[i].tBodies[0].rows;
for(j=1;j<trs.length;j+=2)
trs[j].className="alterna";
}
}
}
function Righello(IDtabella){
trs=document.getElementById(IDtabella).tBodies[0].rows;
/* trs=document.getElementsByTagName("table").tBodies[0].rows; */
for(i=0;i<trs.length;i++){
tds=trs[i].cells;
trs[i].link=tds[tds.length-1].getElementsByTagName("a")[0].href;
trs[i].title= "Visita " + trs[i].link;
trs[i].style.cursor="pointer";
trs[i].onclick=function(){document.location.href=this.li nk};
trs[i].onmouseover = function(){this.className="corrente"};
trs[i].onmouseout = function(){this.className=""};
}
}
</script>