I have a form that asks for some general information (I called it Gen-info) and then a fieldset inside the form in which I ask for other information.
What I'm trying to do is to create a new fieldset asking for the same other info and rename it, but now I just know how to create a copy of exactly this whole form (which asks for the general info too).
By now I'm creating the button like this:
<button type="button" id="btnAddForm" onclick="CloneForm('Gen-info');">Add other info</button>
And I'm using this javascript function:
function CloneForm(formName) {
var formCount = document.forms.length;
var oForm = document.forms[formName];
var clone = oForm.cloneNode(true);
clone.name += "New form " + formCount;
document.body.appendChild(clone);
}
Click here to see the whole code
As you can see, I get to duplicate the whole form, but what I want is to just duplicate the part where it says "Other information 1" and rename it to "Other information 2" when I click and add 1 to the name every time a create a new one. The difference is that now I'm duplicating the whole form every time, and I just want to duplicate the fieldset.
Thank you very much!