I have a problem with a table, I want to add rows in a table with JQuery. At the time of adding and deleting the rows everything is fine, but when you save these rows in a database they are saved in a single record. For example: When saving 5 rows of products, all 5 rows are saved in a single field of the database.
Could you help me please?
<script>
$(document).ready(function () {
$("#nuevalinea").click(function () {
var clonarfila = $("#tablaresponsive").find("tbody tr:last").clone();
$("table tbody").append(clonarfila);
});
$("#tablaresponsive").on('click', '.eliminalinea', function () {
var numeroFilas = $("#tablaresponsive tr").length;
if (numeroFilas > 2) {
$(this).closest('tr').remove();
}
});
});
</script>
<table class="table table-bordered" id="tablaresponsive">
<thead>
<tr>
<%--<th><input type="checkbox" id="check-all" class="flat"></th>--%>
<th>Producto</th>
<th>Cantidad Canjes</th>
<th>Factura</th>
<th>Fecha Factura</th>
</tr>
</thead>
<tbody>
<tr>
<td><%--<input type ="number" name="Producto[]" class="form-control">--%><asp:TextBox ID="TextBox5" type ="number" name="Producto[]" class="form-control" runat="server"></asp:TextBox></td>
<td>
<input type ="number" name="Cantidad Canjes[]" class="form-control">
</td>
<td>
<input type ="number" name="Factura[]" class="form-control">
</td>
<td><input type ="number" name="Fecha Factura[]" id="textboxfila" class="form-control"></td>
<td><button type="button" class="eliminalinea">eliminar</button></td>
</tr>
</tbody>
</table>
<tr>
<th>Producto</th>
<th>Cantidad Canjes</th>
<th>Factura</th>
<th>Fecha Factura</th>
</tr>
</thead>
<tbody>
<tr>
<td><asp:TextBox ID="TextBox5" type ="number" name="Producto[]" class="form-control" runat="server">
</asp:TextBox></td>
<td>
<input type ="number" name="Cantidad Canjes[]" class="form-control">
</td>
<td>
<input type ="number" name="Factura[]" class="form-control">
</td>
<td><input type ="number" name="Fecha Factura[]" id="textboxfila" class="form-control"></td>
<td><button type="button" class="eliminalinea">eliminar</button></td>
</tr>
</tbody>
</table>
<button type="button" id="nuevalinea" class="btn btn-danger"><span class="glyphicon glyphicon-plus"></span> FILA</button>
</div>