I need to generate in JavaScript a new row on a table but with empty cell without a select who need to be the same as the other row and i want the function to work no matter where is the input in the row
here’s my function to add empty row and cells
// Insert new row in the table when clicking on the + button
// tableid: Id of the element to update
function AddRows(tableid){
var table = document.getElementById(tableid);
var rowCount = table.rows.length;
var cellCount = table.rows[0].cells.length;
var row = table.insertRow(rowCount);
var editContent = !row.isContentEditable;
row.contentEditable = editContent;
row.setAttribute('onkeyup', "Disabled();");
row.setAttribute('onclick', "SetSelectedRow(this)");
row.setAttribute('id', 'Combo_row'+(row.rowIndex - 1)); //Set the id of the row
row.setAttribute('class', 'default');
for(var i =0; i < cellCount; i++){
var cell = 'cell'+i;
cell = row.insertCell(i);
cell.id = 'Combo_cell' + i
}
}
I also found this function but she copy the rows and keep the content of every cells not only the select
/* function to add row with a select */
function addSelect(SelectTableId) {
var T = document.getElementById(SelectTableId);
var R = document.querySelectorAll('tbody .AddRowClass')[0];
var C = R.cloneNode(true);
T.appendChild(C);
}