My form has two fields are short description and long description initially the form fileds names are section[new][1][description] and section[new][1][ldescription]
I would like to generate clone form fields which generate names like section[new][2][description] and section[new][2][ldescription]. each time i clone new form it should generate form fields names with increment id in between like section[new][incrementid goes here][description]
How to achieve this using regex or any other jquery techniques?
Here is code i'm using for form clonning
jQuery("button.add").on("click", clone);
function clone(){
var clone = jQuery(this).parents(".pbone_section_default").clone()
.appendTo("#section_list")
.attr("id", "pbone_section_default_" + cloneIndex)
.find("*")
.each(function() {
// here we can put any logic to achieve desire element name
this.name = logic goes here;
})
.on('click','button.delete',remove);
};
cloneIndex?