我有一个php表,我希望能够删除我选择的行,但我不知道如何去做这件事。这是我删除的javascript:php javascript删除单个行
// When a delete button is pressed in one of the rows
function deleteCurrentRow(whatrow)
{
//deletes the approriate row according to what button was pressed
if (hasLoaded) {
var delRow = whatrow.parentNode.parentNode;
deleteRows(delRow);//sends the row for deletion to the function to be deleted
}
}
function deleteRows(rowforDeletion)
{
if (hasLoaded) {
var rowPos = rowforDeletion.sectionRowIndex;//postion of the row for deletion
rowforDeletion.parentNode.deleteRow(rowPos);//deletes row
increment = increment -1;
}
}
这里是我的PHP表:
<table border="1" cellspacing="5" id="tblmarkscheme" style="float: center;">
<thead>
<tr>
<th colspan="5">Template</th>
</tr>
<tr>
<th>Mark</th><th>Criteria</th><th>Delete</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT maxMark, criteria FROM mark ";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" ."<input type = text name = text size = 1 id = mark value = ". $row['maxMark'].">" ."</td>";
echo "<td>"."<textarea>".$row['criteria']. "</textarea>"."</td>";
echo "<td>"."<input type = button value = Delete onclick = deleteCurrentRow(this);/>"."</td>";
echo "</tr>";
}
?>
</tbody><!--elements added onload and when button pressed -->
</table>
我想删除表中的各行有一个按钮,按下
我太傻了,所有我需要做的是把回报,并添加'它 – 2012-03-23 13:55:45