【发布时间】:2019-07-23 16:18:50
【问题描述】:
我正在尝试在我的 HTML 中运行一个脚本,构建一个包含数据的表格。我有一个值范围,我只希望这个 For 循环在该范围内的最后一项上运行。这是我开始使用的代码。
<? for(var i=0;i<rodsAmt.length;i++){ ?>
<? if(i>=rodsAmt.length) { ?>
<tr>
<td><?= rodsAmt[i]; ?></td>
</tr>
<? } ?>
<? } ?>
【问题讨论】:
-
您可以通过这种方式在 Google Apps 脚本中构建 html:stackoverflow.com/a/55680044/7215091
-
这是一个从电子表格中的数据构建 html 表的方法:stackoverflow.com/a/56479763/7215091
-
或在此处了解模板化 html 中的 scriptlet:developers.google.com/apps-script/guides/html/templates
-
欢迎。请添加minimal reproducible example。
-
您遇到的具体问题是什么?另外,'我只希望这个 For 循环在范围内的最后一项上运行是什么意思?查看 Cooper 对此问题的回答,了解如何循环遍历数组并在 GAS 中以 HTML 格式显示它stackoverflow.com/questions/54204282
标签: javascript for-loop google-apps-script