Reputation: 75
I'm getting this array of variables from Meta4 ERP to populate a table.
<script type="text/javascript">
var planDayJS = {date: 26/12/2011, planName: 2011 PT - Vacation Days, dayType: Full Day,dayStatus: ACCEPTED}
PlannedDaysJS.push(planDay);
</script>
<script type="text/javascript">
var planDayJS = {date: 27/12/2011, planName: 2011 PT - Vacation Days, dayType: Full Day,dayStatus: ACCEPTED}
PlannedDaysJS.push(planDay);
</script>
...
<script type="text/javascript">
var planDayJS = {date: 28/12/2011, planName: 2011 PT - Vacation Days, dayType: Full Day,dayStatus: ACCEPTED}
PlannedDaysJS.push(planDay);
</script>
<script type="text/javascript">
var planDayJS = {date: 29/12/2011, planName: 2011 PT - Vacation Days, dayType: Full Day,dayStatus: ACCEPTED}
PlannedDaysJS.push(planDay);
</script>
I cant' see how I can use it.
It should be one array but it seems to me many arrays.
Any help?
Upvotes: 1
Views: 89
Reputation: 377
Here is an example of array filling. You have n objects with its parameters that you push one by one in predefined array. After that you can do with it what you like.
var PlannedDaysJS = new Array();
PlannedDaysJS.push({"par1" : 1, "par2" : 2});
PlannedDaysJS.push({"par1" : 3, "par2" : 4});
PlannedDaysJS.push({"par1" : 5, "par2" : 6});
PlannedDaysJS.push({"par1" : 7, "par2" : 8});
var tblOutput = "<table border='1' width='100%'>";
for (var i=0; i<PlannedDaysJS.length; i++) {
tblOutput += "<tr>";
tblOutput += "<td>" + PlannedDaysJS[i].par1 + "</td>";
tblOutput += "<td>" + PlannedDaysJS[i].par2 + "</td>";
tblOutput += "</tr>";
}
tblOutput += "</table>";
document.getElementById("tbl").innerHTML = tblOutput;
<div id="tbl"></div>
Upvotes: 1