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

158
Views
Obtener casilla de verificación de valor y empujar en matriz

¿Me pueden ayudar sobre cómo hacer que los valores de la casilla de verificación sean una matriz de datos? Codifico así y no obtengo ningún resultado. Gracias por ayudarme.

En mi html:

 <input class="form-check-input delete-checkbox" type="checkbox" name="checkbox[]" id="checkbox" value="{{ $item->id }}"data-id="{{ $item->id }}">

En mi JS:

 function multiple_delete(id) { const selected = []; $(".form-check input[type=checkbox]:checked").each(function () { selected.push(this.value); }); if (selected.length > 0) { dataid = selected.join(","); $.ajax({ url: "multiple-delete", type: "POST", data: +dataid, success: function (data) { if (data["success"]) { alert(data["success"]); } else { alert(data["error"]); console.log(data); } }, error: function (data) { alert(data.responseText); }, }); } }

Mi salida:

salida de la consola

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

0

En primer lugar, está utilizando el selector incorrecto. Debe cambiar .form-check en javascript a .form-check-input o .delete-checkbox . También puede obtener fácilmente los valores de las casillas de verificación seleccionadas utilizando el método .map() de jquery.

Cambia tu código javascript a algo como esto

 function multiple_delete(id) { const selected = $(".delete-checkbox:checked").map((i, el) => el.value).get(); if (selected.length > 0) { $.ajax({ url: "multiple-delete", type: "POST", data: selected.join(","), success: function (data) { if (data["success"]) { alert(data["success"]); } else { alert(data["error"]); console.log(data); } }, error: function (data) { alert(data.responseText); }, }); } }
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!