I have a series of select fields that is created when I click the "Add" button. The select fields are created within an unordered list, and it goes a little like this:
<li><select name="fieldname1"></select><input type='button' name='delbtn1'></li>
<li><select name="fieldname2"></select><input type='button' name='delbtn2'></li>
<!--etc-->
As you can see, I've given a sequence in the names. This is to allow me to do server side scripting after the form is submitted.
I'm also allowing the user to delete the list item, but I would like to still retain the sequence naming after deletion. This would mean: if I delete "fieldname2" in between "1" to "3", I would like to resequence it to "1", and "2".
I've attempted to use the .each() method to go through each list item, but am unable to rename the name correctly.Don't really know what went wrong here.
JS Fiddle here: http://jsfiddle.net/kosherjellyfish/JsW3a/3/