0
這次我將一些問題傳遞給我已經創建的html表中。需要將數組中的值插入到html表中
這是我到目前爲止的代碼:
<table id="FinalTable">
<tr>
<td align="center">FECHA</td>
<th colspan="12" align="center">EVENTOS</th>
</tr>
<tr>
<th></th>
<td align="center">HORA INICIO</td>
<td align="center">SUMMARY</td>
<td align="center">DESCRIPTION</td>
<td align="center">LOCATION</td>
<td align="center">CREATED</td>
<td align="center">CREATOR_EMAIL</td>
<td align="center">STARTDATE</td>
<td align="center">START_DATE</td>
<td align="center">START_DATETIME</td>
<td align="center">START_TIMEZONE</td>
<td align="center">END_DATE</td>
<td align="center">END_DATETIME</td>
<td align="center">END_TIMEZONE</td>
</tr>
<tr>
<td align="center">(First date and so on)</td>
<td align="center">(Events detalized)</td>
</tr>
</table>
<br>
<script type="text/javascript" language="javascript">
document.write("<br><br><br>It's the end of the world as we know it!</br> </br></br>");
var ar = <?php echo json_encode($newarray) ?>;
for (var i = 0; i < ar.length; i++) {
for (var j = 0; j < ar[i]['Eventos'].length; j++) {
if(ar[i]['Eventos'][j].isArray !== 'undefined'){
document.write(
'<td><tr> ' + "fecha_inicio" + ' ' + ar[i]['Eventos'][j]['fecha_inicio'] + '</tr></td>' +
' ' + "hora_inicio" + ' ' + ar[i]['Eventos'][j]['hora_inicio'] +
' ' + "summary" + ' ' + ar[i]['Eventos'][j]['summary'] +
' ' + "description" + ' ' + ar[i]['Eventos'][j]['description'] +
' ' + "location" + ' ' + ar[i]['Eventos'][j]['location'] +
' ' + "created" + ' ' + ar[i]['Eventos'][j]['created'] +
' ' + "creator_email" + ' ' + ar[i]['Eventos'][j]['creator_email'] +
' ' + "startdate" + ' ' + ar[i]['Eventos'][j]['startdate'] +
' ' + "start_date" + ' ' + ar[i]['Eventos'][j]['start_date'] +
' ' + "start_datetime" + ' ' + ar[i]['Eventos'][j]['start_datetime'] +
' ' + "start_timezone" + ' ' + ar[i]['Eventos'][j]['start_timezone'] +
' ' + "end_date" + ' ' + ar[i]['Eventos'][j]['end_date'] +
' ' + "end_datetime" + ' ' + ar[i]['Eventos'][j]['end_datetime'] +
' ' + "end_timezone" + ' ' + ar[i]['Eventos'][j]['end_timezone'])
}
}
}
所以,基本上我不知道如何插入一切document.write
後進入該表的去字段中的值。
請有人幫助我嗎?
非常感謝最親愛的堆垛機!
這與PHP有什麼關係? – Qirel
爲什麼不用PHP填充表格而不是Javascript? – Barmar
一些明智的代碼縮進將是一個好主意。 它可以幫助我們閱讀代碼,更重要的是它可以幫助您調試代碼**。 您可能會被要求在幾周/幾個月內修改此代碼,最後您會感謝我。 – GrumpyCrouton