Good afternoon, I'm breaking my heart to solve this, could anyone help?
I have a textarea in which the user will paste the data from an excel spreadsheet, the data comes in as follows:
10 | produto1 | 1 | 3
20 | prodto2 | 2 | 4
These pipes do not go in the textarea I put to separate better here
I get this data and use split () to remove the spaces and save the data in an array.
After that I want to insert this data into a table, with its columns, if I put a line only in the textarea, it works, if I put more than one I do not know how I do to 'break' the row in the table . Here's my script below:
addItens = function() {
var valor = document.getElementById('texto').value;
var retorno = valor.split(" ");
var newRow = $("<tr>");
var cols = "";
for(i = 0; i < retorno.length; i++)
{
cols += '<td>'+retorno[i]+'</td>';
}
cols += '<td class="actions">';
cols += '<button class="btn btn-large btn-danger" onclick="RemoveTableRow(this)" type="button">Remover</button>';
cols += '</td>';
newRow.append(cols);
$("#products-table").append(newRow);
return false;
};
})(jQuery);