Generate Unique Name and ID based on table's first row
The code below will generate unique name and id based on table's first row, paste it before </body> $(document).ready(function () { var rows = $("table tbody tr"); rows.each(function (i) { var inputs = $(this).find('input'); i++; inputs.eq(0).attr('id', 'txtTitle'+i ) .attr('name', 'txtTitle'+i ); inputs.eq(1).attr('id', 'txtLink'+i ) .attr('name', 'txtLink'+i ); }); }); Let's say for example you have this line of code in HTML: <table id="matt"> <tbody> <tr> <td><input id="txtTitle" name="txtTitle" type="text" value="title" /></td> <td><input id="txtLink" name="txtLink" type="text" value="link" /></td> </tr> <tr> <td>...