I am currently working on creating a form to display items and need a fresh text field when the user clicks the ADD button.
function addNewItem() { //ADD ROW AND CLONE
var table = document.getElementById('tbl');
var tbody = document.createElement('tbody');
table.insertBefore(tbody, null);
var clone = document.getElementById('cln').cloneNode(true);
tbody.insertBefore(clone, null);
}
function deleteItem() { //DELETE ROW
var table = document.getElementById('tbl');
var delRow = table.rows.length;
if (delRow > 1) {
table.deleteRow(delRow - 1);
}
}
<tr id="cln"> //CALL CLONE FUNCTION
<div align="center">1</div>
</td>
// PHP Database Connection Code
I'm facing difficulties in setting up the text field value for when the user clicks the button. I want to use a cloning function instead of copying old values from the first row and column. Is there a way to make the index auto-increment?