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

220
Vistas
Java Script for loop only iterates through the first row on a table

My for loop will iterate multiple times but any changes I want to make to the cells only happens in the first row. The counters for the rows and the cells all go up but the only cells that are updated are the ones in the first row. I've even examined through the console and nothing is happening to the other rows.

Note: I only want the cells with the ID's to be updated

var table = document.getElementById("myTable");

for (var r = 0, n = table.rows.length; r < n; r++) //for every row
{
  for (var c = 0, m = table.rows[r].cells.length; c < m; c++) //for every cell
  {
    var x = document.getElementsByTagName("td")[c];
    console.log("row counter " + r);
    console.log("cell counter " + c);

    if (x.id == "wed_asso") {
      schedule_wed();
      x.innerHTML = wed_associate;
    }

    if (x.id == "asso") {
      schedule();
      x.innerHTML = associate;
    }
  }
}
<table id="myTable">
  <tr>
    <th> </th>
    <th> Wednesday </th>
    <th> Thursday</th>
    <th> Friday</th>
    <th> Saturday</th>
    <th> Thursday</th>
    <th> Friday</th>
    <th> Saturday</th>
  </tr>
  <tr>
    <td> TDR</td>
    <td>John</td>
    <td id="asso"></td>
    <td>Alec</td>
    <td id="asso"></td>
    <td id="asso"></td>
    <td>Alec</td>
    <td id="asso"></td>
  </tr>
  <tr>
    <td> </td>
    <td id="wed_asso"> </td>
    <td id="asso"> </td>
    <td id="asso"> </td>
    <td id="asso"> </td>
    <td id="asso"> </td>
    <td id="asso"> </td>
    <td id="asso"> </td>
  </tr>
</table>

about 4 years ago · Juan Pablo Isaza
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