我从Meta4 ERP获取这一组变量来填充表格。
<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>
我不能'看我怎么用它。
它应该是一个数组,但在我看来很多数组。
任何帮助?
答案 0 :(得分:1)
这是一个数组填充的例子。您有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;
&#13;
<div id="tbl"></div>
&#13;