Hi,
I was wondering if anyone could help me with an issue I am having. I am trying to pull data from an HTML table and use the numbers to plot a graph. Here's the code...
- <table width="400" border="1" id="table1">
- <tr id="hole-num">
- <td>Hole</td>
- <td class="hole">1</td>
- <td class="hole">2</td>
- <td class="hole">3</td>
- <td class="hole">4</td>
- <td class="hole">5</td>
- <td class="hole">6</td>
- <td class="hole">7</td>
- <td class="hole">8</td>
- <td class="hole">9</td>
- </tr>
- <tr id="player-score">
- <td>Ross</td>
- <td class="score">4</td>
- <td class="score">4</td>
- <td class="score">5</td>
- <td class="score">4</td>
- <td class="score">4</td>
- <td class="score">5</td>
- <td class="score">4</td>
- <td class="score">5</td>
- <td class="score">3</td>
- </tr>
- </table>
- <script class="code" type="text/javascript" language="javascript">
- $('#table1 tr').each(function() {
- //loops through each td and store contents in score
- //holes = $(this).find("td.hole").html();
- scores = $(this).find("td.score").html();
- });
- $(document).ready(function(){
- //plot graph
- plot6 = $.jqplot('graph', [[scores]], {
- });
- });
- </script>
From what I understand; the script iterates through the table looking for the TD's with the class ".score" and extracts the data to store in "scores". This is then used to plot the graph.
The problem I am having is that it only plots 1 point on the graph.
Can anyone tell my why this is and help me fix this problem?
