Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8916883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:21:46+00:00 2026-06-15T05:21:46+00:00

Dynamic data/tables printed from the DB. Need to get how many times have the

  • 0

Dynamic data/tables printed from the DB. Need to get how many times have the teams WON, TIED, LOST. Super new to jQuery and no clue what to start coding with (?!). I was thinking of first getting the row where Chelsea appears, then comparing scores, using arrays to store W, T, L — and printing the results at the end (?).

This is what the table looks like:

<table>
<tr id="12">
   <td class="238 ekipi_1">Chelsea</td>
   <td class="231 ekipi_2">ManU</td>
   <td class="goals_238">4</td>
   <td class="goals_231">2</td>
</tr>

<tr id="13">
   <td class="242 ekipi_1">Reading</td>
   <td class="238 ekipi_2">Chelsea</td>
   <td class="goals_242">3</td>
   <td class="goals_238">3</td>
</tr>

<tr id="16">
   <td class="251 ekipi_1">Swansea</td>
   <td class="238 ekipi_2">Chelsea</td>
   <td class="goals_251">5</td>
   <td class="goals_238">3</td>
</tr>
</table>

The result would be:

          W   T   L

Chelsea | 1 | 1 | 1 |
Reading | 0 | 1 | 0 |
ManU    | 0 | 0 | 1 |

Any tips for a head start would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:21:47+00:00Added an answer on June 15, 2026 at 5:21 am

    To Read the initial data and build the Object you can do this..

        var teams = {
        "Chelsea": {"W": 0, "T": 0, "L": 0},
        "ManU": {"W": 0, "T": 0, "L": 0},
        "Reading": {"W": 0, "T": 0, "L": 0},
        "Swansea": {"W": 0, "T": 0, "L": 0}
    };
    
    $('table tr').each(function() {
        var $this = $(this);
        var team1 = $this.find('td:eq(0)').text();
        var team2 = $this.find('td:eq(1)').text();
        var score1 = $this.find('td:eq(2)').text();
        var score2 = $this.find('td:eq(3)').text();
    
        if(+score1 === +score2){
            teams[team1]["T"] =  +teams[team1]["T"] +1; 
            teams[team2]["T"] =  +teams[team2]["T"]+1; 
        }  
        else if(+score1 > +score2){
            teams[team1]["W"] =  +teams[team1]["W"]+1; 
            teams[team2]["L"] =  +teams[team2]["L"]+1; 
        }
        else{
            teams[team1]["L"] =  +teams[team1]["L"]+1; 
            teams[team2]["W"] =  +teams[team2]["W"]+1; 
        }        
    });
    
    // Print the data
    
    $.each(teams, function(key,value){
        var $clone = $('#template');
        $clone.find('.team').html(key);
        $clone.find('.score:eq(0)').html(value["W"]);
        $clone.find('.score:eq(1)').html(value["T"]);   
        $clone.find('.score:eq(2)').html(value["L"]);
        $('#output').append($clone.html());
    });
    

    Check Fiddle

    You can read the teams object and print it out once you are done..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some PHP code that generates dynamic tables of data on the fly.
I have an ASP.NET Dynamic Data application that includes two tables, Departments and KPI's
GETPIVOTDATA(Data,{Dynamic reference to another sheet},Field,Item) I'm trying to get my formula to be super
I have a Dynamic Data 4 site using LinqToSql (.dbml) for 2 tables with
I am generating editable data grids from tables using dynamic data, however, i am
I have two Data Tables and these are completely dynamic. These would be generated
I have a dynamic range in an Excel sheet. DATA_TABLE =OFFSET(DATA!$B$3,0,0,COUNTA(DATA!$B:$B)-1,0) I want to
Dynamic Data question: I have 2 fields of type Nullable<DateTime> on my model When
I have created a Dynamic Data site against an Entity Framework Model I have
I have create a LINQ-to-SQL project in Visual Studio 2010 using Dynamic Data. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.