Scusate ragazzi sono che non si fa ma... non ho il tempo di leggere il Dom... così hotrovato questo esempio molto chiaro tra l'altro.
<script>
function start() {
// get the reference for the body
var mybody=document.getElementsByTagName("body").item( 0);
// creates an element whose tag name is TABLE
mytable = document.createElement("TABLE");
// creates an element whose tag name is TBODY
mytablebody = document.createElement("TBODY");
// creating all cells
for(j=0;j<1;j++) {
// creates an element whose tag name is TR
mycurrent_row=document.createElement("TR");
// creates an element whose tag name is TD
mycurrent_cell=document.createElement("TD");
mycurrent_cell1=document.createElement("TD");
// creates a Text Node
currenttext=document.createTextNode('<input type\'text\'>');
currenttext1=document.createTextNode("ok2");
// appends the Text Node we created into the cell TD
mycurrent_cell.appendChild(currenttext);
mycurrent_cell1.appendChild(currenttext1);
// appends the cell TD into the row TR
mycurrent_row.appendChild(mycurrent_cell);
mycurrent_row.appendChild(mycurrent_cell1);
// appends the row TR into TBODY
mytablebody.appendChild(mycurrent_row);
}
// appends TBODY into TABLE
mytable.appendChild(mytablebody);
// appends TABLE into BODY
mybody.appendChild(mytable);
// sets the border attribute of mytable to 2;
mytable.setAttribute("border","2");
}
</script>
funziona correttamente solo che ho un limite nella creazione di html all'interno del TD
currenttext=document.createTextNode ('<input type\'text\'>')
visualizza in realtà il testo per comè non come html....
in realtà è chiaro che volgio inserire un campo input text
come posso fare.
Grazie.