I have a table where I can select the number of items in an order. And in each row I have a number of 01
to 15
sequential where it identifies the quantity of items.
The problem is that when I delete an item, the interesting thing is that the numbers that identify each line update automatically and become random. Do you understand? Note: The list is made in table.
<table id="table_itens" class="table table-striped">
<thead>
<tbody>
<tr id="exc_01">
<td>01</td><!-- Estes números que eu quero atualizar dinamicamente -->
</tr>
<tr id="exc_02">
<td>02</td><!-- Estes números que eu quero atualizar dinamicamente -->
</tr>
<tr id="exc_03">
<td>03</td><!-- Estes números que eu quero atualizar dinamicamente -->
</tr>
</tbody>
</table>
JavaScript code:
<script type="text/javascript" language="javascript">
function adicionaItemPedido(){
var contador = (cont < 10) ? '0'+ cont++ : cont++;
$("#table_itens").append(
'<tr id="exc_'+ contador +'">\n\
<td><b>'+ contador +'</b></td>\n\
<td>'+ referencia_estofado[0] +'</td>\n\
<td><input type="hidden" class="id_est_revest_aux" value="'+ $("#revestimento_aux").val() +'" />'+ revestimento[0] +'</td>\n\
<td><input type="hidden" class="id_padrao_aux" value="'+ $("#cod_padrao option:selected").val() +'" />'+ $("#cod_padrao option:selected").text() +'</td>\n\
<td>'+ (($("#revestimento_aux_2").val() === 'undefined') ? "-" : $("#revestimento_aux_2").val()) +'</td>\n\
<td>'+ (($("#cod_padrao_2").val() === 'undefined') ? "-" : $("#cod_padrao_2").val()) +'</td>\n\
<td>'+ referencia_estofado[1] +'</td>\n\
<td>'+ $("#quantidade").val() +'</td>\n\
<td>'+ $("#valor_unitario").val() +'</td>\n\
<td>'+ $("#desconto_acrescimo").val() +'</td>\n\
<td>'+ $("#valor_total").val() +'</td>\n\
<td><button type="button" class="btn btn-danger btn-xs btnRemover"><i class="glyphicon glyphicon-remove" ></i> Remover</button></td>\n\
</tr>');
}
</script>