【发布时间】:2017-11-23 04:44:26
【问题描述】:
我正在使用 PHP,并且我有一个想要动态填充的表。
<table>
<tr>
<th>This One</th>
<th>That One</th>
<th>The Other One</th>
</tr>
<tr>
<td>Final This</td>
<td>Final That</td>
<td>Final The Other</td>
</tr>
</table>
我正在填充表数据 onchange,我希望将数据添加到 上方 标有“Final blah”的行。
每个新行都有用于填充每个单元格的数据。
是否有一些功能可以通过 PHP 实现这一点,也许利用一些 JavaScript?
编辑: 我想得到一个看起来像这样的最终产品:
<table>
<tr>
<th>This One</th>
<th>That One</th>
<th>The Other One</th>
</tr>
<tr> Dynamically added row. Cells already populated from database</tr>
<tr> Next row of data from the database</tr>
<tr> The next row should **ALWAYS** be the last row</tr>
<tr>
<td>Final This</td>
<td>Final That</td>
<td>Final The Other</td>
</tr>
</table>
请注意,我要保留一个标题行!
我想在标题行和带有“最后的东西”的行之间插入行。
最后一行始终存在。
【问题讨论】:
-
使用一些 ajax 和 jquery 来找到最后一行并将其添加到上面。
-
需要动态创建
tr,添加数据并追加到tbody -
试试在你的 PHP 中使用 echo 吧?
-
是什么驱动了行的添加。 OnChange 什么?
-
我改变什么都没关系。 something 的 onchange 将一些行插入到标题行下方的
中。
标签: javascript php html