我对 Javascript 很陌生,所以我不确定我是否做对了。首先,我使用 JSON 创建一个数组对象“providerlisting”。接下来我正在创建一个 for 循环,它应该循环遍历 html,直到 JSON 数组中没有更多列表。我不确定我的语法是否正确。我对问这些问题也很陌生,所以如果我做错了,我很抱歉。
for (var i=0;i<providerlisting.length;i++)
{ document.write('<div class="entry panel row">
<div class="large-4 columns first">
<div class="name">'providerlisting.nametitle[i]'</div>
<div class="specialty">'providerlisting.caretype[i]'</div>
<div class="peferred">'providerlisting.preferredprovider[i]'</div>
</div>
<div class="large-3 columns second">
<div class="address">'providerlisting.address1[i]'<br />
'providerlisting.address2[i]'<br />
'providerlisting.citystatezip[i]'
</div>
</div>
<div class="large-3 columns third">
<img src="'providerlisting.coverage[i]'" alt="example">
</div>
<div class="large-2 columns fourth">
<div class="status">'providerlisting.status[i]'</div>
<a data-dropdown="actionsMenu2" class="actions button small secondary round dropdown" href="#">Actions</a><br>
<ul id="actionsMenu2" data-dropdown-content="" class="f-dropdown">
<li><a href="'providerlisting.psn[i]'">Generate PSN</a></li>
<li><a href="'providerlisting.dcontact[i]'">Download Contact</a></li>
<li><a href="'providerlisting.save[i]'">Save to Provider List</a></li>
<li><a href="'providerlisting.rating[i]'">View Healthgrades Rating</a></li>
</ul>
</div>
</div>
');