my script code and html looks like this when I try to add a new line, it automatically selects the property of the last flag, if the chekbox is checked, than in the new line add checkbox with the check to check check check check check in new row
script code
<script type="text/javascript">
$("input.tr_clone_add").live('click', function() {
var $tr = $(this).closest('.tr_clone');
var $clone = $tr.clone();
$clone.find(':text').val('');
$tr.after($clone);
});
</script>
Tablelooks like that:
<table id="table-data" width="100%">
<tr class="tr_clone">
<td><input type="checkbox" autofocus name="status[]" value="Y"></td>
<td>
<select name="group_id[]">
<option>Select User</option>
<?php
$selectGroup = "SELECT group_id,group_name
FROM `group`";
$res = mysql_query($selectGroup);
while($row = mysql_fetch_array($res))
{
echo '<option value="'.$row['group_id'].'">'.$row['group_name'].'</option>';
}
?>
</select>
</td>
<td><textarea name="address[]" rows="3" cols="35" placeholder="Enter Address"></textarea></td>
<td><input type="button" name="add" value="Add" class="tr_clone_add"></td>
</tr>
</table>
source
share