You can get the new index by assessing how many $('.attr_entry')
elements exist. Then, you can combine find()
and prop()
to set the name of the radio buttons.
Amend your clone()
line as follows:
var newIndex = $('.attr_entry').length;
$('.attr_entry:first').clone(true).removeClass('existent').insertAfter('.attr_entry:last').find('input[type="radio"]').prop('name', 'designator['+newIndex+']');
Please also be advised that the id
attribute for elements should be unique, so you might want to consider updating that at the same time (using the same prop()
method).