How to get individual td values from PivotTables without clicking the row

0

I have a button that sends the form, and inside the form have the respective fields, inside the form has a table that dynamically brings the data of the bank that is allows editing the values of each line:

    $("#update-baixa").click(function () {

        var item = $("[data-idparcela]").closest("tr").children('td:eq(1)');

        console.log(item.val());

    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><tableid="tablemdlreceita" class="table table-sm table-bordered table-responsive">
    <thead>
        <tr>
            <th>Documento</th>
            <th>Vlr Programado</th>
            <th>Dt Vencto</th>
            <th colspan="2" class="text-center">Ações</th>
        </tr>
    </thead>
    <tbody><tr>
            <td>FR212</td>
            <td>220.00</td>
            <td>30/01/2019</td>
            <td align="center">
                <a class="omdleditreceita" data-idparcela="3">Editar</a>
            </td>
        </tr>
        <tr>
            <td>FR212</td>
            <td>400.00</td>
            <td>25/01/2019</td>
            <td align="center">
                <a class="omdleditreceita" data-idparcela="4">Editar</a>
            </td>
        </tr>
    </tbody><tbody>
        <tr>
            <td colspan="9" align="center">
                <div class="pagination-wrap">
                    <ul class="pagination"><li><a href="/add-data.php?page_no=1" style="color:red;">1</a></li></ul>                                                
                </div>
            </td>
        </tr>
    </tbody>
</table>

                        <button type="button" id="update-baixa" class="btn btn-primary"><span class="fas fa-plus"></span>Salvar</button>

Only you are not getting the individual value of each td from the column | Programmed Vlr |

    
asked by anonymous 13.12.2018 / 11:20

1 answer

1

I do not know if the way your code is implemented will perform well, but if you want you can get the values of each td just by setting your position from the data attributes.

$("#update-baixa").click(function() {

  var tam = $("[data-idparcela]").length;

  for (var i = 0; i < tam; i++) {
    for(var j = 1; j<tam; j++) {
      var item = $("[data-idparcela]:eq("+i+")").parents("tr").children("td:eq("+j+")");

      console.log(item.text());

     }
  }

});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><tableid="tablemdlreceita" class="table table-sm table-bordered table-responsive">
  <thead>
    <tr>
      <th>Documento</th>
      <th>Vlr Programado</th>
      <th>Dt Vencto</th>
      <th colspan="2" class="text-center">Ações</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>FR212</td>
      <td>220.00</td>
      <td>30/01/2019</td>
      <td align="center">
        <a class="omdleditreceita" data-idparcela="3">Editar</a>
      </td>
    </tr>
    <tr>
      <td>FR212</td>
      <td>400.00</td>
      <td>25/01/2019</td>
      <td align="center">
        <a class="omdleditreceita" data-idparcela="4">Editar</a>
      </td>
    </tr>
  </tbody>
  <tbody>
    <tr>
      <td colspan="9" align="center">
        <div class="pagination-wrap">
          <ul class="pagination">
            <li><a href="/add-data.php?page_no=1" style="color:red;">1</a></li>
          </ul>
        </div>
      </td>
    </tr>
  </tbody>
</table>

<button type="button" id="update-baixa" class="btn btn-primary"><span class="fas fa-plus"></span>Salvar</button>
    
13.12.2018 / 12:34