I recently posted this question to figure out how to create a table of data in HTML/JS using Parse.com
I am now working with a new template, where I am dealing with an already existing div table and want to populate it dynamically with my Parse.com data.
Here is the HTML code from the website template:
<div class="sidebarbox">
<div class="sidebarbox-title">
<h3>Latest Results</h3>
</div>
<!-- TABLE -->
<div class="fixture-row">
<a href="#">
<div class="fixture-row-left">Consectetur FC
<div>?</div>
</div>
<div class="fixture-row-right">
<div>?</div>Voluptate Cillum FC</div>
</a>
</div>
</div>
And this is the HTML/javascript code I currently have which successfully creates a HTML table with my Parse.com data inside.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript"
src="http://www.parsecdn.com/js/parse-1.2.18.min.js"></script>
</head>
<body>
<h3>Current season First Team results</h3>
<table id="first-team-results-table">
<col width="150">
<col width="150">
<col width="80">
<col width="150">
<col width="80">
<tbody>
<tr>
<th>Opposition</th>
<th>Competition</th>
<th>Home/Away</th>
<th>When</th>
<th>Score</th>
</tr>
</tbody>
</table>
<h3>Current season Reserve Team results</h3>
<table id="reserve-team-results-table">
<col width="150">
<col width="150">
<col width="80">
<col width="150">
<col width="80">
<tbody>
<tr>
<th>Opposition</th>
<th>Competition</th>
<th>Home/Away</th>
<th>When</th>
<th>Score</th>
</tr>
</tbody>
</table>
<script type="text/javascript">
src="//www.parsecdn.com/js/parse-1.2.18.min.js";
Parse.initialize("jtYdOpyKQ6SXFLqaGcpoG20yXyX9KlPHUzgg6jAJ", "TMRegOlA8nCui4sTN8d9hmQG8k8FVeESc2GnRwVH");
var firstTeamResults = Parse.Object.extend("Results");
var query = new Parse.Query(firstTeamResults);
query.equalTo("team", "DVFC Firsts");
query.descending("dateTime");
query.find(
{
success: function(results)
{
for (var i = 0; i < results.length; i++) {
var object = results[i];
(function($) {
$('#first-team-results-table').append('<tr><td>'
+ object.get('oppositionName')
+ '</td><td>'
+ object.get('competition')
+ '</td><td>'
+ object.get('homeAway')
+ '</td><td>'
+ object.get('dateTime')
+ '</td><td>'
+ object.get('score')
+ '</td></tr>');
})(jQuery);
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
var reserveTeamResults = Parse.Object.extend("Results");
var query = new Parse.Query(reserveTeamResults);
query.equalTo("team", "DVFC Reserves");
query.descending("dateTime");
query.find(
{
success: function(results)
{
for (var i = 0; i < results.length; i++) {
var object = results[i];
(function($) {
$('#reserve-team-results-table').append('<tr><td>'
+ object.get('oppositionName')
+ '</td><td>'
+ object.get('competition')
+ '</td><td>'
+ object.get('homeAway')
+ '</td><td>'
+ object.get('dateTime')
+ '</td><td>'
+ object.get('score')
+ '</td></tr>');
})(jQuery);
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
</script>
</body>
</html>
Any help on how to combine the two, and get the Parse.com data into the div table would be highly appreciated.