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

245
Visualizações
Get number value from td innerText

This is my table:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>Documento senza titolo</title>
        <link href="Champions%20League/Champion%20League.css" rel="stylesheet" type="text/css">
    </head>
    <body style="border-style: none; border-collapse: collapse; empty-cells: show; table-layout: auto; font-family:Verdana, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif">
        <table ;="" style="width: 80%; text-align: center; margin-left: auto; margin-right: auto;"
            id="db" cellspacing="2" cellpadding="2" border="1">
            <tbody>
                <tr>
                    <td width="10%">09-11-1996</td>
                    <td width="10%">Norimberga</td>
                    <td style="text-align: right;" width="15%">Germania</td>
                    <td width="10%">3-0</td>
                    <td style="text-align: left;" width="15%">Irlanda del Nord</td>
                    <td width="25%">Qualificazioni Mondiali 1998 </td>
                    <td width="5%"><strong>1</strong></td>
                </tr>
            </tbody>
        </table>
        <script>
            function GetCellValues() {
            var table = document.getElementById('db');
            var total = 0
            for (var r = 0, n = table.rows.length; r < n; r++) {
            total += parseInt(table.rows[r].cells[7].innerText)      
            }
            alert(total);
            }
            GetCellValues()
        </script>
    </body>
</html>

The script at the end should repeat for a certain number of rows. But I can't extrapolate the numeric value present in the last cell (in this case, 1), since the final value of the total variable is NaN. How can I fix it?

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