I have 3 input types :
<input type="checkbox" name="check[0]" value="randomval">
<input type="checkbox" name="check[0]" value="randomval">
<input type="checkbox" name="check[0]" value="randomval">
I have a jquery script that is triggered on a click and append 3 input type like the following, the script just keeps adding the trio of inputs, as much as needed by the user:
<input type="checkbox" name="check[1]" value="randomval">
<input type="checkbox" name="check[1]" value="randomval">
<input type="checkbox" name="check[1]" value="randomval">
There is also a delete button that deletes the 3 inputs.
I'm looking for a way that on each clicks, Jquery loops though all the checkboxes and rename the "name" attribute so it's never missing a number. Because right now i'm having a problem that when the user deletes inputs I have some names like :
check[0], check[3]
missing :
check[1] and check [2]
So is there a way to loop on each click and reset all the names to be from 1 to number of trio inputs I have ?
Thanks