vedi se ti può servire
codice:<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <TITLE></TITLE> <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript> <!-- function button1_onclick() { /* var tabella = document.getElementById("Tabella1"); if(!tabella) return; var i, j; var tabella_n = tabella.childNodes.length; for(i = 0; i < tabella_n; i++) if(tabella.childNodes[i].tagName != undefined) alert(tabella.childNodes[i].tagName); var tb = tabella.getElementsByTagName("TBODY")[0]; var r = -1, c = -1; for(i = 0; i < tb.childNodes.length; i++) if(tb.childNodes[i].tagName != undefined) { //alert(tb.childNodes[i].tagName); r++; c = -1; for (j = 0; j < tb.childNodes[i].childNodes.length; j++) { if(tb.childNodes[i].childNodes[j].tagName != undefined) { c++; alert(r + ", " + c + ": " + tb.childNodes[i].childNodes[j].innerHTML); } } } return; */ var tb = document.getElementById("Tabella1"); if(!tb) return; var i, j; 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++) alert(i + ", " + j + ": " + colonneTD[j].innerHTML); var colonneTH = righe[i].getElementsByTagName("TH"); for(j = 0; j < colonneTH.length; j++) alert(i + ", " + j + ": " + colonneTH[j].innerHTML); } } //--> </SCRIPT> </HEAD> <BODY> <table border="1" id="Tabella1" cellpadding="2" cellspacing="0"> <tr> <th width="30" height="30">a1</th> <th width="30" height="30">b1</th> <th width="30" height="30">c1</th> <th width="30" height="30">d1</th> </tr> <tr> <td width="30" height="30">a2</td> <td width="30" height="30">b2</td> <td width="30" height="30">c2</td> <td width="30" height="30">d2</td> </tr> <tr> <td width="30" height="30">a3</td> <td width="30" height="30">b3</td> <td width="30" height="30">c3</td> <td width="30" height="30">d3</td> </tr> <tr> <td width="30" height="30">a4</td> <td width="30" height="30">b4</td> <td width="30" height="30">c4</td> <td width="30" height="30">d4</td> </tr> </table> <INPUT type="button" value="Button" id=button1 name=button1 LANGUAGE=javascript onclick="return button1_onclick()"> </BODY> </HTML>

Rispondi quotando