Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

213
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda