我如何使用此 Javascript 数据来填充 table?
How can I use this Javascript data to populate table?
我正在从 Meta4 ERP 获取这个变量数组来填充 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>
我不知道如何使用它。
应该是一个数组,但在我看来是很多数组。
有什么帮助吗?
这里是一个数组填充的例子。您有 n 个对象及其参数,您将这些对象一个一个地推送到预定义的数组中。之后你可以用它做你喜欢的事。
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>
我正在从 Meta4 ERP 获取这个变量数组来填充 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>
我不知道如何使用它。
应该是一个数组,但在我看来是很多数组。
有什么帮助吗?
这里是一个数组填充的例子。您有 n 个对象及其参数,您将这些对象一个一个地推送到预定义的数组中。之后你可以用它做你喜欢的事。
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>