There is a dynamic table. The task is to ensure that after filling in the table with information on the button, all the data goes to the table in the database which should be created on the fly.
HTML:
<p><strong>Имя таблицы</strong></p> <p><input maxlength="25" size="40" ></p> <table> <tbody id="contacts"> <tr> <td colspan="3"><a href="#" onclick="addContact (); return false">Добавьте контакт</a></td> </tr> <tr> <td width = 20 ></td> <td>Имя </td> <td>Email</td> <td>text</td> </tr> </tbody> </table> Js
function addContact () { var tb = document.getElementById ('contacts'), ro = tb.insertRow (-1), ce = ro.insertCell (-1); if (tb.rows.length == 2) ce.innerHTML = ' '; else { var im = document.createElement ('img'); im.src = 'del.jpg'; im.onclick = function () {tb.deleteRow (this.parentNode.parentNode.rowIndex)} ce.appendChild (im); } NUM = (!self.NUM) ? 1 : ++NUM; var ce = ro.insertCell (-1), inp = document.createElement ('input'); inp.name = 'name' + NUM; ce.appendChild (inp); var ce = ro.insertCell (-1), inp = document.createElement ('input'); inp .name = 'email' + NUM; ce.appendChild (inp); var ce = ro.insertCell (-1), inp = document.createElement ('input'); inp.name = 'text' + NUM; ce.appendChild (inp); }