è realizzabile uno scenario di questo tipo:
//------------------------------------------------------------- //visualizza-nasconde una colonna di una tabella //id=identificativo tabella //colonna=indice colonna //tb=true->visibile, false->invisibile //------------------------------------------------------------- function VisColonna(id,colonna,tf) { /* var tt = document.getElementById(id); var rr = tt.rows; var cc; for(i=0;i<rr.length;i++) { cc = rr[i].childNodes; for(j=0;j<cc.length;j++) if(j==colonna) cc[j].style.display = (tf)? '': 'none'; } */ var tabella = document.getElementById(id); if(!tabella) return; var tb = tabella.getElementsByTagName("TBODY")[0]; var righe = tb.getElementsByTagName("TR"); for(i = 0; i < righe.length; i++) { var colonneTD = righe[i].getElementsByTagName("TD"); for(j = 0; j < colonneTD.length; j++) if(colonna == j) colonneTD[j].style.display = (tf)? '': 'none'; var colonneTH = righe[i].getElementsByTagName("TH"); for(j = 0; j < colonneTH.length; j++) if(colonna == j) colonneTH[j].style.display = (tf)? '': 'none'; } } //------------------------------------------------------------- //visualizza-nasconde una riga di una tabella //id=identificativo tabella //colonna=indice riga //tb=true->visibile, false->invisibile //------------------------------------------------------------- function VisRiga(id,riga,tf) { /* var tt = document.getElementById(id); var rr = tt.rows; var cc; cc = rr[riga].childNodes; for(j=0;j<cc.length;j++) cc[j].style.display = (tf)? '': 'none'; */ var tabella = document.getElementById(id); if(!tabella) return; var tb = tabella.getElementsByTagName("TBODY")[0]; var righe = tb.getElementsByTagName("TR"); for(i = 0; i < righe.length; i++) { if(riga == i) { righe[i].style.display = (tf)? '': 'none'; var colonneTD = righe[i].getElementsByTagName("TD"); for(j = 0; j < colonneTD.length; j++) colonneTD[j].style.display = (tf)? '': 'none'; var colonneTH = righe[i].getElementsByTagName("TH"); for(j = 0; j < colonneTH.length; j++) colonneTH[j].style.display = (tf)? '': 'none'; } } }
Torna al forum | Feed RSS