Javascript looping through elements and adding to table

m7390

New Member
I'm having trouble finding a solution that will help me loop through a bunch of elements and putting the chosen values into a table. I've been able to withdraw some values but the method isn't dynamic. Here is an example: \[code\]var Table = { "credit": { "link": "site link", "logoUrl": "logo url", "message": "message" }, "groups": [ { "labels": [ { "name": "Western Conference", "type": "conference" }, { "name": "Central Division", "type": "division" } ], "standings": [ { "stats": [ { "name": "gp", "value": 20 }, { "name": "w", "value": 17 }, { "name": "l", "value": 0 }, { "name": "gf", "value": 64 }, { "name": "ga", "value": 37 }, { "name": "gd", "value": 27 }, { "name": "pts", "value": 37 } ], "team": { "id": 12345, "link": "team link", "name": "team name", "shortName": "team" } }, \[/code\]This is the structure of the elements. So far I've used this, \[code\]document.getElementById("sGamesPlayed").innerHTML=Table.groups[0].standings[0].stats[0].value;\[/code\]to withdraw values. However there are more teams, stats and divisions so I would need some kind of loop to go through the elements and put the into a dynamic table. Any pointer or links to other similar problem solution will be much appreciated.
 
Back
Top