0
我创建了一个HTML表格并使用数据库中的值填充。现在我想为这个table创建编辑功能。我在表格的每一行添加了Edit按钮。我需要知道相应的rowID按下相关的编辑按钮。我使用java脚本来获得该行的ID,但不幸的是我只得到第一行的细节。我想我需要把一些for循环。我需要此ID来传递另一个页面,以便填充相应条目的值,并且用户可以编辑条目并保存它们。我正在开发dotnet,但我不想使用任何gridview控件来做到这一点)。使用Java脚本从HTML表格获取单元格数据按下编辑按钮
如果您有任何示例代码或解决方案,请寄给我。
<tr id= "listings">
<td style="width:16%; vertical-align:top; border-bottom: solid 1px black;" id = "ids">@@[email protected]@</td>
<td style="width:16%; vertical-align:top; border-bottom: solid 1px black; text-align:right;">@@[email protected]@</td>
<td style="width:2%; vertical-align:top; border-bottom: solid 1px black; text-align:right;"> </td>
<td style="width:16%; vertical-align:top; border-bottom: solid 1px black;">@@[email protected]@</td>
<td style="width:16%; vertical-align:top; border-bottom: solid 1px black;">@@[email protected]@</td>
<td style="width:16%; vertical-align:top; border-bottom: solid 1px black; text-align:right;">@@[email protected]@</td>
<td style="width:2%; vertical-align:top; border-bottom: solid 1px black; text-align:right;"> </td>
<td style="width:16%; vertical-align:top; border-bottom: solid 1px black; text-align:right;">
<button name = "editButton" type = "button" value = "Edit" onclick="test()">
Edit
</button>
</td>
</tr>
<script type="text/javascript">
function test() {
var elTableRow = document.getElementById("listings");
var elTableCells = elTableRow.getElementsByTagName("td");
alert(elTableCells[0].innerText);
}
</script>
有人请重播此... – BenoitParis 2010-09-10 10:14:09