Capture line only

1

I have a table created in array, and the modal button opens a table for selection of units of weight / measure, but when the selection is captured it fills the whole table as in the picture below. How do I fill in the line only?

Opentablestructurewhenclickingonmodal

<tableclass='tabletable-bordered'><thead><tr><th>  Unidade </th><th>  Descrição</th></tr></thead><tbody><?phpinclude("conn.php");

       $result = "SELECT * FROM cadunid ORDER BY descricao";
       $resultado = mysqli_query($conn, $result);

       while($row = mysqli_fetch_assoc($resultado)) {
           echo "<tr class='btn-default'>";
               echo "<td class='get-value'>". $row['codigo'] ."</td>";
               echo "<td class='get-value-codigo'>". $row['descricao'] ."</td>";
           echo "</tr>";
       }                      
   ?>
   </tbody>
</table>

table structure shown in the image above

<table class="table table-bordered"><!-- Iniciando a Tabela -->
    <thead>
       <tr><!-- Início dos Títulos da Tabela / Cabeçalho -->
         <th><button type="button" class="" data-toggle="modal" data-target="#myModal">Unidade >>                 </button></th>
         <th>Preço Custo</th>
         <th>Preço Venda</th>
         <th>Peso Bruto</th>
         <th>Peso Liquido</th>
         <th>Qtd. Emb.</th>
       </tr><!-- Fim dos Títulos da Tabela / Cabeçalho -->
    </thead>

    <tbody id='prprod'><!-- Início do Corpo da tabela / Quantidade de linhas e colunas -->
    <?php for($i = 0; $i <= 5; $i++){ //coloquei este valor para testar ?>        
    <tr>                                                   
      <input type="hidden" maxlength="6"  name="recnum[]" style="border:none; width:100%; background-color: transparent;">
      <td><input type='text' name="unidad[]" class="unidade-input" style="border:none; width:100%; background-color: transparent;">                                                               
      <td><input type="text" maxlength=""  name="preco_custo[]" placeholder="" style="border:none; width:100%; background-color: transparent;"></td>
      <td><input type="text" maxlength=""  name="preco_venda[]" placeholder="" style="border:none; width:100%; background-color: transparent;"></td>
      <td><input type="text" maxlength=""  name="peso_bruto[]" placeholder="" style="border:none; width:100%; background-color: transparent;"></td>
      <td><input type="text" maxlength=""  name="peso_liquido[]" placeholder="" style="border:none; width:100%; background-color: transparent;"></td>
      <td><input type="text" maxlength=""  name="qtde_embalagem[]" placeholder="" style="border:none; width:100%; background-color: transparent;"></td>
    </tr>
     <?php } ?>
    </tbody><!-- Fim do Corpo da tabela / Quantidade de linhas e colunas -->

</table><!-- Finalizando a Tabela -->

script used to capture drive selected by user

<script>
  $(document).on('click', '.get-value', function() {
    var value = $(this).text();
    $('.close').trigger('click');
    $('.unidade-input', "tr").find.val(value); /* tentei desta forma porém continua preenchendo toda tabela */
  });

  $(document).on('click', '.get-value-codigo', function() {
      var value = $(this).siblings('.get-value').text();
      $('.close').trigger('click');
      $('.unidade-input').val(value);
  });
</script>
    
asked by anonymous 06.11.2017 / 13:48

1 answer

0

Would you consider your case if you inserted a line dynamically every time the user finishes filling the modal data?

  

When you click on the unidade button open the modal with the fields to be   completed after completing the fields using the javascript itself.   insert a row in the table.

This allows you to enter as many rows as you want. And initially your table will contain only the header content.

    
06.11.2017 / 23:49