Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8711743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:57:28+00:00 2026-06-13T04:57:28+00:00

I need to clone a fieldset inside of a cloned fieldset. So My regular

  • 0

I need to clone a fieldset inside of a cloned fieldset.
enter image description here

So My regular structure is like

enter image description here

When I click add new agenda field it successfully clones bigger field like

enter image description here

But when I click add new file it only adds new field to parent field not to current field

enter image description here

My code is like

<div id="agenda_placeholder">
    <div id="agenda_template">
    <fieldset>
        <legend>Agenda Details</legend>

        <ol>
            <li>
                <label for=topic_name>Topic Name</label>
                <input id=topic_name name=topic_name type=text placeholder="ACAT Briefing" required autofocus>
            </li>
            <li>
                <label for=topic_time>Time</label>
                <input id=topic_time name=topic_time type=text placeholder="2.00 - 2.30 ">
            </li>
            <li>
                <label for=presenter>Presenter</label>
                <input id=presenter name=presenter type=text placeholder="Name LastName">
            </li>


            <li>
            <div id="file_placeholder">
            <div id="file_template">
                <fieldset>
                    <legend>File Details</legend>

                        <ol>
                            <li>
                                    <label for=file_description>File Description</label>
                                    <input id=file_description name=file_description type=file_description placeholder="Ex. Weather Stats">
                            </li>
                            <li>
                                    <label for=file_name>File Name</label>
                                    <input id=file_name name=file_name type=file_name placeholder="Exact file name Eg:weather.docx">
                            </li>
                            </ol>
                        </div> <!-- file_template -->
                     </div> <!-- file_placeholder -->   
                     <button type="button" name="AddNewFile" onclick="Add();">Add New File</button> 
                </fieldset>
            </li>
         </ol>
        </div> <!-- agenda_template -->
    </div> <!-- agenda_placeholder -->
        <button type="button" name="AddNewAgenda" onclick="Add_Agenda();">Add New Agenda Field</button>
    </fieldset>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script>
        var _counter = 0;
function Add() {
    _counter++;
    var oClone = document.getElementById("file_template").cloneNode(true);


    oClone.id += (_counter + "");
    document.getElementById("file_placeholder").appendChild(oClone);
}

function Add_Agenda() {
    _counter++;
    var oClone = document.getElementById("agenda_template").cloneNode(true);
    oClone.id += (_counter + "");
    document.getElementById("agenda_placeholder").appendChild(oClone);
}

So how can I clone a fieldset inside of a cloned field set?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:57:29+00:00Added an answer on June 13, 2026 at 4:57 am

    first, your html is invalid it has tags overlapping

    in your add function the statement
    document.getElementById(“file_placeholder”)
    will return the first match of id file_placeholder , and that is incorrect.

    what you need is to know which button was clicked and clone its parent div
    and append the cloned div to the grandparent div of the button.

    the same logic can be applied to Add_agenda but you should note to remove added files
    to the agenda you are cloning.

    function Add(btn) {
         _counter++;
        var parentFileTemplate = $(btn).parent("div");
        parentFileTemplate.attr('id',"file_template" + _counter );
        var parentFilePlaceHolder = parentFileTemplate.parent();
        cloned = parentFileTemplate.clone();
        cloned.attr('id',"file_template" + _counter );
        parentFilePlaceHolder.append(cloned);
      }
    

    also you must add this as parameter when calling the function:

    <button type="button" name="AddNewFile" onclick="Add();">
    

    will be:

    <button type="button" name="AddNewFile" onclick="Add(this);">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clone the id and then add a number after it like
I need to clone an html block which has some imgs inside, just like
I have some particular need to clone an element (image) and be draggable inside
I have this dropdown. I need clone for my other dropdown lists: <select name=general>
I need create clone repository. but I do not know where can I get
i have a single filed which i need to clone with a clone button
I have an entity that has a few relations. I need to clone this
I need a method that creates an empty clone of an object in a
I need a shallow copy of an java ArrayList , should I use clone()
I am doing little assigment which involves fork,vfork and clone function. I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.