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

111
Vistas
Expandable table

I want to make expandable table like this expandable table filled by PHP script. Now it doesn't work after i added if statement in hidden.foreach(). Do You know why it doesn't work and how to fix this problem ?

echo "<table><thead><th>Product</th><th>Expenses</th><th>Group</th><th>Show more</th></thead>";
    while($row=$show_costs->fetch_assoc())
    {
        $show_more_costs=$conn->query("SELECT `name`,`describtion`,`cost`,`b_date`,`group` FROM `costs` WHERE `pId`='".$row['pId']."'");
        echo "<tr><td>".$row['pId']."</td><td>".$row['costs']."</td><td>".$$row['group']."</td><td><span id='show_more'>▼</span></td></tr>";
        //Detailed costs which i want to expand after clicking this
        while($row_md=$show_more_costs->fetch_assoc())
        {
            echo "<tr class='hidden'><td>".$row_md['name']."</td><td>".$row_md['describtion']."</td><td>".$row_md['cost']."</td><td>".$row_md['b_date']."</td><td>".$row_md['group']."</td></tr>";
        }
    }
    echo "</table>";

//This is my JS code:

show_more=document.querySelectorAll('#show_more');
hidden=document.querySelectorAll('.hidden');
show_more.forEach(show_more =>{
  show_more.addEventListener('click',event=>{
    hidden.forEach(hidden=>{
      if(hidden.style.display==='none')
      {
        hidden.style.display='table-row';
      }
      if(hidden.style.display==='table-row')
      {
        h1.style.display='none';
      }
    })
  })
})

What do I have to fix?

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