Guest User

Untitled

a guest
Apr 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. var verificarTotal = function () {
  2. var $seleccionados = $(".chkseleccion:checked"),
  3. $cajas = $("#totalc"),
  4. $kilogramos = $("#totalp"),
  5. $t1 = $("#total1"),
  6. $t2 = $("#total2"),
  7. totalCajas = 0,
  8. totalKilogramos = 0;
  9.  
  10. $.each($seleccionados, function (indice, fila) {
  11. if ($(fila).is(':checked')) {
  12. totalCajas += parseInt($(fila).closest('tr').find('.inputcajas').html());
  13. totalKilogramos += parseInt($(fila).closest('tr').find('.inputpeso').html());
  14. $(fila).closest('tr').find('.inputvalor').val("1");
  15. } else {
  16. $(fila).closest('tr').find('.inputvalor').val("0");
  17. }
  18. });
  19.  
  20.  
  21. $cajas.val(totalCajas);
  22. $kilogramos.val(totalKilogramos);
  23. $t1.text(totalCajas);
  24. $t2.text(totalKilogramos);
  25.  
  26. };
  27.  
  28. <table id="datatable-buttons" class="table table-striped table-bordered dataTable no-footer dtr-inline" role="grid" aria-describedby="datatable-buttons_info" style="width: 100%;">
  29. <thead>
  30. <tr role="row">
  31. <th class="sorting_asc" tabindex="0" aria-controls="datatable-buttons" rowspan="1" colspan="1" style="width: 20px;" aria-sort="ascending" aria-label="">#</th>
  32. <th class="sorting" tabindex="0" aria-controls="datatable-buttons" rowspan="1" colspan="1" style="width: 50px;" aria-label="">Peso de tarima</th>
  33. <th class="sorting" tabindex="0" aria-controls="datatable-buttons" rowspan="1" colspan="1" style="width: 50px;" aria-label="">Cajas de tarima</th>
  34. <th class="sorting" tabindex="0" aria-controls="datatable-buttons" rowspan="1" colspan="1" style="width: 50px;" aria-label="">Enviar</th>
  35. </thead>
  36.  
  37. <tbody>
  38. <?php if(!empty($tarimas)): ?>
  39. <?php foreach($tarimas as $tarimas): ?>
  40. <tr role="row" class="odd">
  41. <td tabindex="0" class="sorting_1">
  42. <input type="number" value="0" name='valores[]' class="inputvalor">
  43. <input type="hidden" value="<?php echo $tarimas->id;?>" name='inputseleccion[]'><?php echo $tarimas->id; ?>
  44. </td>
  45. <td class="inputpeso"><?php echo $tarimas->peso; ?> kgs</td>
  46. <td class="inputcajas"><?php echo $tarimas->cajas; ?> cajas</td>
  47. <td>
  48. <div class="checkbox">
  49. <label>
  50. <input type="checkbox" value="" name='inputselect[]' class="chkseleccion"> Añadir
  51. </label>
  52. </div>
  53. </td>
  54. </tr>
  55. <?php endforeach; ?>
  56. <?php endif; ?>
  57. </tbody>
  58. </table>
Add Comment
Please, Sign In to add comment