How to copy selected row
How to copy selected row
Hello.
This is my code
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#addrow").click(function() {
var row = $('#ORDERLINES tbody>tr:last').clone(true).insertAfter('#ORDERLINES tbody>tr:last');
var index = $("#ORDERLINES tbody>tr").length;
$("td:eq(0)", row).text(index);
$("td:eq(1) input", row).attr("name", "item_no" + index).attr("id", "item_no" + index)
$("td:eq(2) input", row).attr("name", "item-desc" + index).attr("id", "item-desc" + index)
return false;
});
});
</script>
</head>
<body>
<a id="addrow" href="#"><strong>Add Row</strong></a></p>
<table id="ORDERLINES" border="0" align="left" cellpadding="2" cellspacing="1" bgcolor="#999999">
<thead>
<tr>
<th bgcolor="#ecf6fc" scope="col">No.</th>
<th bgcolor="#ecf6fc" scope="col">Item Number</th>
<th bgcolor="#ecf6fc" scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td bgcolor="#ecf6fc" align="center">1</td>
<td bgcolor="#ecf6fc"><input name="item_no1" type="text" id="item_no1" value="" /></td>
<td bgcolor="#ecf6fc"><input name="item-desc1" type="text" id="item-desc1" value="" /></td>
</tr>
<tr>
<td bgcolor="#ecf6fc" align="center">2</td>
<td bgcolor="#ecf6fc"><input name="item_no2" type="text" id="item_no2" value="" /></td>
<td bgcolor="#ecf6fc"><input name="item-desc2" type="text" id="item-desc2" value="" /></td>
</tr>
</tbody>
</table>
</body>
</html>
My problem now is, how can I copy selected row and append to the bottom of the table ?