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

208
Vistas
Undefined error when printing my HTML Table

I wanted to print only my HTML Table contents within the webpage that I am currently working on, however, when I tried to print it, it says "undefined". Why is that so? and is there any other way I could print my table that is connected in a database? Here are my codes:

        <script>
        function printDiv(tableview) {
         var printContents = document.getElementsByClassName(tableview).innerHTML;
         var originalContents = document.body.innerHTML;
    
         document.body.innerHTML = printContents;
    
         window.print();
    
         document.body.innerHTML = originalContents;
        }
        </script>
        
        <div class="printBtn">
        <img src="images/printBtn_hover.png" class="printBtn_hover" onclick="printDiv('tableview')">
        <img src="images/printBtn.png" class="printBtn" alt="print" onclick="printDiv('tableview')">
        </div>

<div class="tableview">
<table class="table">

    <tr>
    <th class="theader">Entry Code</th>
    <th class="theader">User ID Number</th>
    <th class="theader">Name</th>
    <th class="theader">Date of Visit</th>
    <th class="theader">Time of Visit</th>
    </tr>
    
    <tbody>
    <?php
    
    while ($row = mysqli_fetch_array($searchResult)):?>
    
    <tr  id="trow">
        <td class="tdata"><?php echo $row['qr_id'];?></td>
        <td class="tdata"><?php echo $row['idNum'];?></td>
        <td class="tdata"><?php echo $row['lastName'].", ".$row['firstName']?></td>
        <td class="tdata"><?php echo $row['date'];?></td>
        <td class="tdata"><?php echo $row['time'];?></td>
    </tr>
    
    <?php endwhile; 
    ?>
    
    </tbody>
    
</table>
</div>
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