Click here to Skip to main content
15,904,828 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<script type="text/javascript" >

$(document).ready(function(){

$("#but").click(function (){

var newRow = $('#tb tbody>tr:last').clone(true).appendTo('table')
.find('input').val('');
return false;

});
$("#delete").click(function(){
if($('#tb tbody>tr:last').closest("tr")==$('#tb tbody>tr:first')){
break;
}
else{
$('#tb tbody>tr:last').remove();
return false;
}
});


});

</script>


And my html file contain


XML
<form name="form1" action="interview.php" method="POST"><button id="but">add</button><button id="delete">delete</button>
<table id="tb" >
<tbody>
<tr><td>name:</td><td><input type="text" name="name[]"></td><td>ACC NO</td><td><input type="text" name="acc_no[]"></td></tr>
</tbody>

</table>
<input type="submit" value="submit">
</form>
Posted
Updated 26-Aug-13 0:20am
v2
Comments
Akhil Das 26-Aug-13 6:39am    
thank you very much that works..i d'nt know how to perform null check in each input type..

1 solution

Hi.. check this once...
C#
$("#delete").click(function() {
            var RowCount = $('#tb tbody>tr').size();
            if (RowCount > 1) {
                $('#tb tbody tr:last').remove();
                return false;
            }
        });
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900