It was example
Now :

nel - number of "workfieldset", =1 when page loaded

You need create construction like this:

nel++;
$(fromClone).find("input").each(function() {
  var s = $(this).attr("name");
  s.replace(/([^\[]+)\[0\]/, "$1["+nel+"]");
  $(this).attr("name", s);
});

And for "label":

$(fromClone).find("label").each(function() {
  var s = $(this).attr("for");
  s.replace(/([^\[]+)\[0\]/, "$1["+nel+"]");
  $(this).attr("name", s);
});

It can be function:
function abc(fieldset, element, attribute) {
  $(fieldset).find(element).each(function() {
    var s = $(this).attr("attribute");
    s.replace(/([^\[]+)\[0\]/, "$1["+nel+"]");
    $(this).attr("name", s);
  });
}

Reply via email to