I am struggling to get this for cycle to show only 1 column in html. At the moment it works but it gives me the values for the 3 columns, please check the example above:
The columns I have in spreadsheet:
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapsetest"><span class="glyphicon glyphicon-file">
</span>Extensions</a>
</h4>
</div>
<div id="collapsetest" class="panel-collapse collapse">
<div class="panel-body">
<? var linkdata = getLinks(); ?>
<? for (var i = 0; i < linkdata.length; i++) { ?>
<table class="table">
<tr>
<? for (var j = 0; j < linkdata[i].length; j++) { ?>
<td><span class="<?= linkdata[i][2] ?>"></span><a target="_blank" href="<?= linkdata[i][1] ?>"><?= linkdata[i][j] ?></a></td>
<? } ?>
</tr>
<? } ?>
</table>
</div>
</div>
</div>
You don't need the inner loop over j, since there is one entry per row. Instead of
<tr>
<? for (var j = 0; j < linkdata[i].length; j++) { ?>
<td><span class="<?= linkdata[i][2] ?>"></span><a target="_blank" href="<?= linkdata[i][1] ?>"><?= linkdata[i][j] ?></a></td>
<? } ?>
</tr>
you should have
<tr>
<td>
<span class="<?= linkdata[i][2] ?>"></span>
<a target="_blank" href="<?= linkdata[i][1] ?>"><?= linkdata[i][0] ?></a>
</td>
</tr>
(Also, it's not clear if you really wanted that span to be empty, or if you meant it to contain the link, in which case </span>
should be moved after </a>
.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.