Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
show alert if checked checkbox with different attr in javascript

In my project, I need to check if the data-id-row values are equal to the data-id-row values of the checked table rows when the checkboxes are checked, return a value if it is equal, and a message if it is not equal. Show it.

this is my rows

<table>
<thead>
   <tr>
  <th>
     <input type="checkbox" name="id[]">
  </th>
  <th>
     first name
  </th>
  <th>
     last name
  </th>
   </tr>
</thead>
<tbody>
   <tr id="6">
  <td><input type="checkbox"></td>
  <td>hamid</td>
  <td>hamidi</td>
   </tr>
   <tr id="7">
  <td><input type="checkbox"></td>
  <td>john</td>
  <td>tyler</td>
   </tr>
   <tr id="8">
  <td><input type="checkbox"></td>
  <td>john</td>
  <td>smith</td>
   </tr>
  </table>

How can I do that?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this, it will show you id's of all checked rows:

var trs= document.getElementsByTagName("tr");

for (var i = 0; i < trs.length; i++){
var tr = trs[i];
var checks = tr.getElementsByTagName("input");
if (checks.length > 0 && checks[0].checked)
     alert(tr.id)
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda