Salve ragazzi sto cercando di creare una tabella dinamicamente via DOM... solo che non succede assolutamente nulla nč errori nč altro... ho provato lo stesso algoritmo sostituendo all'elemento table l'elemento div e a tr analogamente dv, mentre ho utilizzato span per i td... e la cosa funziona. Qualcuno sa dirmi se gli elementi tabella hanno un comportamento particolare?... posto il codice per comprensione:
codice:
function creaTabella(wichParent,numA, numB, rowInt, colInt){
tabella=document.createElement('table');
tabella.setAttribute('width','100%');
tabella.style.setAttribute('border','1px solid #F00');
testi=new Array();
spans=new Array();
divs=new Array();
for(i=0;i<numA;i++){
testi[i]=new Array();
spans[i]=new Array();
check=new Array();
divs[i]= document.createElement('tr');
divs[i].style.setAttribute('borderBottom','2px solid #00F');
divs[i].style.setAttribute('whiteSpace','nowrap');
for (j=0;j<numB;j++){
spans[i][j]=document.createElement('td');
spans[i][j].style.setAttribute('borderRight','1px solid #ccc');
spans[i][j].style.setAttribute('width','100');
spans[i][j].style.setAttribute('paddingLeft','3px');
spans[i][j].style.setAttribute('paddingRight','5px');
if(j>0){
testi[i][j]=document.createTextNode('testo'+i+j);
spans[i][j].appendChild(testi[i][j]);
divs[i].appendChild(spans[i][j]);
}else{
check[i]=document.createElement('input');
check[i].setAttribute('type', 'text');
divs[i].appendChild(spans[i][j]);
}
}
tabella.appendChild(divs[i]);
}
document.getElementById(wichParent).appendChild(tabella);
}
la funzione viene chiamata sull'evento onload e il parent č un div inserito nel body...
Attendo consigli.