Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
seleccione todas las casillas de verificación usando la función .map

Entonces, logré crear una matriz de filas marcadas y las vinculé a un botón. Cuando se hace clic en el botón, todas las filas seleccionadas se abrirán en nuevas pestañas.

Ahora mi problema es que no logré seleccionar todo. Probé varias formas de colocar las filas seleccionadas en una matriz y la que funciona es este código, así que lo seguiré usando:

 toggleTick_Change() var chktArr =[]; function toggleTick_Change(){ chktArr = $('.single-row-checkbox:checkbox:checked').map(function(){ return $(this).val(); }).get(); console.log('the checked values are: ' + chktArr); $('#conditional-part').show(); }

Pero aún no logró seleccionar todo cuando se selecciona otra casilla de verificación.

A continuación se muestran los botones que abren nuevas pestañas:

 function btnPrintCNT_Click(){ console.log('This is from button , the checked values are: ' + chktArr); for(let i = 0 ; chktArr.length > i ; i++){ window.open('?mod=admin&action=consignment&id=' + chktArr[i]); } }

Código para la casilla de verificación HTML

 <input type="checkbox" id="chkAll" value="{$rows.id}" name="chktArr" style="width: 15px; height: 15px;" class="all-row-checkbox" onchange="toggleTick_Change()" /> <input type="checkbox" id="chkT{$rows.id}" value="{$rows.id}" name="chktArr" style="width: 15px; height: 15px;" class="single-row-checkbox" onchange="toggleTick_Change()" />

Código para el botón HTML:

 <div class="input-group " role="group" aria-label="..." style="width: 85px; margin-top: 2px; " > <span class="input-group-btn"> <button id="btnPrintCNT" type="button" class="btn btn-sm btn-primary" style="margin: 2px; width: 100px; margin-left: 20px; float: left;" onclick="javascript:btnPrintCNT_Click()">CNT</button> </span> </div>

Cualquier sugerencia es muy apreciada.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

ok, lo resolví. agrego la declaración if else correctamente. Tampoco uso la función toggleTick_Change onevent y uso class en su lugar. Agrego la clase js-checkbox en mi código html de checkbos.

a continuación se muestra lo principal que cambio en mi función de casillas de verificación

 var chktArr =[]; $(document).ready(function() { $('.js-checkbox').change(function() { chktArr = $('.single-row-checkbox:checkbox:checked').map(function(){ return $(this).val(); }).get(); console.log('the checked values are: ' + chktArr); $('#conditional-part').show(); if ($(this).attr('id') === 'chkAll'){ if ($(this).prop('checked') === true){ $('.single-row-checkbox').prop("checked", true); chktArr = $('.single-row-checkbox:checkbox:checked').map(function(){ return $(this).val(); }).get(); console.log('the checked values are: ' + chktArr); $('#conditional-part').show(); }else { $('.single-row-checkbox').prop("checked", false); chktArr = $('.single-row-checkbox:checkbox:checked').map(function(){ return $(this).val(); }).get(); console.log('the checked values are: ' + chktArr); } }else{ } }); });

Gracias por todas las sugerencias.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!