Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!