I'm writing a page that includes a button whose function is to add a row to a table on the page. The bare bones of it is: body = document.getElementsByTagName("body")[0]; tbl = document.createElement("table"); tblBody = document.createElement("tbody"); row = document.createElement("tr"); cell = document.createElement("td"); cellText = document.createTextNode("some text"); cell.appendChild(cellText); cell.setAttribute("width", "3%"); row.appendChild(cell); // repeat for a few more cells // add the row to the end of the table body tblBody.appendChild(row); // put the <tbody> in the <table> tbl.appendChild(tblBody); body.appendChild(tbl); PHP: This works great except that when the page is saved, the document tree doesn't get saved, just the default blank table. So my question is twofold: 1) Is there a way to save the document tree? or 2) Is there a better way to append a row to a table on a page that will let you save the finished table when you're done? I can't create the table and fill it in with the button instead opf appending rows, because the button may be used multiple times so I don't know when I start how many rows I'll need. Thanks!
The only way to save the added rows would be by saving them on the server. You could use AJAX to send a message back to the server on the addrow function.