I have a table where I allow the user to insert / remove lines when I find it necessary, but what I need and can not adapt is to insert a block of Columns and Lines, but without success, I will try to show what I have. I have this table:
I'mtryingtoaddthiswholeblockwhentheuserclicksAdicionarLinha
,IalreadydidsomesearchesandIdidnotfindanythingsimilarandmyknowledgeinJquery
islittle,almostnothing.
Theskeletonofthetablelookslikethis:
<tablewidth="60%" border="1" id="tabela-herdeiro" class="table">
<tbody>
<tr>
<td width="8%">Nome</td>
<td width="23%"> </td>
<td width="10%">Nacionalidade</td>
<td width="27%"> </td>
<td width="10%">Estado Civil</td>
<td width="22%"> </td>
</tr>
<tr>
<td>Residência</td>
<td> </td>
<td>RG</td>
<td> </td>
<td>CPF</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Cônjuge</td>
<td> </td>
<td>RG</td>
<td> </td>
<td>CPF</td>
<td> </td>
</tr>
<tr>
<td colspan="6" align="right"><button class="btn btn-large btn-danger btn-xs" onclick="RemoveTableRowPessoa(this)" type="button">Remover</button></td>
</tr>
</tbody>
Add Line
JQuery that inserts lines is this:
(function($) { RemoveTableRowPessoa = function(handler) { var tr = $(handler).closest('tr'); tr.fadeOut(400, function(){ tr.remove(); }); return false; }; AddTableRowPessoa = function() { var newRow = $(""); var cols = ""; cols += 'Nome Nacionalidade Estado Civil RG CPF Residênvia Cônjuge RG Cônjuge CPF Cônjuge '; cols += ''; cols += 'Remover'; cols += ''; newRow.append(cols); $("#tabela-herdeiro").append(newRow); return false; }; })(jQuery);
But I could not adapt, as I said