I create a table that contain rows and on last 'td' on each row there is an 'img' to insert new row onClick="addRow()". I want this new row to insert below clicked row. Clearly, if i have row X and row Y and i click on the 'img' on X row then i will get the new row below X and above Y.
am using this code for insertion:
<script>
function addRow()
{
var newRow = document.all("tblGrid").insertRow(-1);
var oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t1'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t2'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t3'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='text' name='t4'>";
}
</script>
<table id="tblGrid" cellspacing="0">
<tr>
<th>Instraction</th>
<th>Result</th>
<th>Time</th>
<th>Date</th>
<th>Add</th>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_instRecordset['instName']; ?></td>
<td><?php echo $row_instRecordset['instValue']; ?></td>
<td><?php echo $row_instRecordset['instTime']; ?></td>
<td><?php echo $row_instRecordset['instDate']; ?></td>
<td><img onClick="addRow()" width="20px" height="20px" src="images/add_32.png"/></td>
</tr>
<?php } while ($row_instRecordset = mysql_fetch_assoc($instRecordset)); ?>
</table>