I am making an application type inventory that according to a purchase invoice can consult the products related to that invoice and can add an input and a button to send certain information to the BD of each product of the invoice. If, for example, there are 5 cans of flavor milk in the invoice, how can I make 5 rows with the text Milk of flavor appear, since each product is individual?
What I have managed to do is that by making an html table add up the total number of products, and according to that result, I draw an html table with that number of rows. What I do not know is how to show the texts.
my code to generate the table is
var suma = 0;
$('#grillaArt tr').each(function() {
suma += parseInt($(this).find('td').eq(1).text() || 0, 10)
})
jQuery = $;
jQuery("#generaTabla").hide().fadeIn("Slow");
var NroFila = suma;
var Cantidad = NroFila * NroFila + 1;
var valor = Cantidad * 1300;
jQuery('#tblTabla tr').next().remove();
var a = 0;
for (var x = 0; x < NroFila; x++) {
Cantidad = Cantidad + x;
valor = valor * Cantidad;
a = a + 1;
jQuery('#tblTabla tr:last').after('<tr>' +
'<td align="left">' + a + '</td>' +
'<td align="left">' + Cantidad + '</td>' +
'<td align="left">' + valor + '</td>' +
'<td align="center"><button>Agregar</button></td></tr>'
);
}
jQuery('#tblTabla tr:odd').css('background-color', '#E9F0F8');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="generaTabla" style="display: none">
<table cellspacing="0" cellpadding="4" border="0" id="tblTabla" style="color: #333333; width: 100%; border-collapse: collapse;">
<tr style="color: White; background-color: #5D7B9D; font-weight: bold;">
<th align="left">Nro</th>
<th align="left">Cantidad</th>
<th align="left">Valor</th>
<th style="text-align:center">Agregar</th>
</tr>
</table>
</div>