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

240
Vistas
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 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