我有一个table. 里面有一个single row for form input elements。我已经把一个命名button为. 当一个用户它会。但是在这里我需要当用户单击按钮添加行时它会。假设现在我有. 当用户单击时,它将显示另一行,但. 这是我已经完成的代码add linebelow that tableclicks on the button add lineadd another row in that tableadd another row with increment idrow_1 id is visibleadd line buttonnewly added row's id will be row_2
<!DOCTYPE HTML>
<html lang="en-IN">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script type="text/javascript" src="jquery1.7.2.js"></script>
<body>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#add-line").click(function() {
var row = jQuery('.prototype tr').clone(true);
row.find("input:text").val("");
row.appendTo('.form-fields table');
return false;
});
});
</script>
<div id="form">
<table id="form-headings">
<tr>
<td width="15%">Id</td>
<td width="16%">Name</td>
<td width="13%">Col3</td>
<td width="14%">Col4</td>
<td width="12%">Col5</td>
</tr>
</table><!--table#form-headings-->
<div id="row_1">
<div class="form-fields">
<table>
<tr>
<td><input type="text" id="form_id" size="5px"/></td>
<td><input type="text" id="form_name" size="5px"/></td>
<td><input type="text" id="form_col3" size="5px"/></td>
<td><input type="text" id="form_col4" size="5px"/></td>
<td><input type="text" id="form_col5" size="5px"/></td>
</tr>
</table>
</div><!--.form-fields-->
</div><!--#row_01-->
<input type="button" id="add-line" value="Add Line" />
</div><!--#form-->
<table class="prototype" style="display:none">
<tr>
<td><input type="text" id="form_id" size="5px"/></td>
<td><input type="text" id="form_name" size="5px"/></td>
<td><input type="text" id="form_col3" size="5px"/></td>
<td><input type="text" id="form_col4" size="5px"/></td>
<td><input type="text" id="form_col5" size="5px"/></td>
</tr>
</table><!--table.prototype-->
</body>
</html>