I am developing the back end of a CMS that I have been working on.
I have a HTML table that I want the user to be able to add and remove rows from. Each row will contain various user inputs (textboxes, checkboxes..). Then when the users has finished it will be saved in the database.
I am wondering what the best way to approach it is.
I guess the table would be something like this:
<table>
<tr>
<td><input name="name_1" type="text" /></td>
<td><input name="address_1" type="text" /></td>
</tr>
<tr>
<td><input name="name_2" type="text" /></td>
<td><input name="address_2" type="text" /></td>
</tr>
<tr>
<td><input name="name_3" type="text" /></td>
<td><input name="address_3" type="text" /></td>
</tr>
</table>
I am imagining I will have a nightmare of a time with giving each element in each row an id and what happens if the user deletes row 2... all the id's after it will need to be reordered.
How best to add and remove rows and maintain sequential ids using JavaScript?