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

159
Views
No puedo obtener la identificación del elemento seleccionado a través de la casilla de verificación con IE

Tengo problemas para recuperar la identificación de los objetos seleccionados a través de la casilla de verificación.

No he puesto todo el código porque es demasiado largo, solo he introducido lo necesario.

 allart.Items.forEach(function (item) { let child = document.createElement("tr"); child.innerHTML = '<td>' + item.id + '</td><td>' + item.title + '</td><td>' + item.date + '</td><td><input type="checkbox" id="myCheck" data-item-id=+item.id+></td>'; table.appendChild(child);

 <table id="my-table" width="90%"> <tr> <th>Id</th> <th>Title</th> <th>Date</th> <th>Selection</th> </tr> </table> <br><br> <input type="button" value="GetID" onclick="getId" />

 function getId() { var cbs = document.querySelectorAll('#my-table input[type="checkbox"]:checked'); console.log(cbs.length); const ids = Array.from(cbs).map(function (cb) { cb.getAttribute("data-item-id") }); console.log(ids); for (let i = 0; i < ids.length; i++) { deleteRow(ids[i]); } }

No puedo obtener la variable ids.

ids devuelven longitud 1 pero data-item-id no está definido.

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

0

Simplemente cambie su declaración de const ids a lo siguiente:

 ids = [] cbs.forEach((checkedBox) => { ids.push(checkedBox.getAttribute("data-item-id")) })

(Violín aquí: https://jsfiddle.net/3madc64u/1/ )

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!