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

  • Home
  • SEARCH
  • 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 9131079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:04:59+00:00 2026-06-17T08:04:59+00:00

Hi this was actually orginally in another question ( HERE ) that had two

  • 0

Hi this was actually orginally in another question (HERE) that had two parts. The first part was solved by @epascarello – thanks again, now just this part remaining, and i don’t seem to get it.

I’m creating a duplicate-able div’s containing checkboxes, on submit it only returns one value for the original input in the console, but no value for any duplicates.

Any help greatly appreciated.

JS Fiddle: http://jsfiddle.net/dawidvdh/EEd7c/

jQuery:

//Clone Tracking
var g_counter = 1;
var d_counter = 1;
var dependant = ["dependant"];
var group;
//Clone Tracking
//General Variables
var relation_input_groups = ["relation-group-1"];
//General Variables
//Generate variables
var relation_fields=[0];
var relation_input ="<label>Spouse</label>"+

                    "<input type='checkbox' value='spouse' class='relationship' name='relationship' />" +
                    "<label>own child</label>"+ 

                    "<input type='checkbox' value='ownchild' class='relationship' name='relationship' />" +
                    "<label>adopted</label>"+ 

                    "<input type='checkbox' value='adopted' class='relationship' name='relationship' />" +
                    "<label>stepchild</label>"+ 

                    "<input type='checkbox' value='stepchild' class='relationship' name='relationship' />" +
                    "<label>parent</label>"+ 

                    "<input type='checkbox' value='parent' class='relationship' name='relationship' />" +
                    "<label>inlaw</label>"+ 

                    "<input type='checkbox' value='inlaw' class='relationship' name='relationship' />" +
                    "<label>brother</label>"+ 

                    "<input type='checkbox' value='brother' class='relationship' name='relationship' />" +
                    "<label>other</label>"+ 

                    "<input type='checkbox' value='other' class='relationship' name='relationship' />";
//Generate variables
jQuery(document).ready(function(e) {
    //populate jquery generated fields
    jQuery(relation_fields).each(function() {
        jQuery(relation_input).appendTo('#relation-group-1');
    });
    //populate jquery generated fields
    //Cloning Function
    jQuery('#clone').click(function() {
        clone_dependant();
    });
    function clone_dependant() {
        // Store the value of the previous Id to insert the cloned div..
        var oldId = g_counter;
        g_counter++;
        currentdep ='dependant-'+g_counter;
        // Clone the Dependant Div and set a new id
        var $clonedDiv = jQuery('#dependant-1').clone(false).attr('id', 'dependant-'+g_counter);
        var relation_newDiv = 'relation-group-'+ g_counter;
        // Find div's inside the cloned object and set a new id's
        $clonedDiv.find('#relation-group-1').attr('id',"relation-group-" + g_counter );
        // You don't need to Loop thru the inputs to set the value
        $clonedDiv.find('input').val('');
        $clonedDiv.find('input:checkbox').removeAttr('checked');
        // Insert the cloned object 
        $clonedDiv.insertAfter("#dependant-" + oldId);

        relation_input_groups.push(relation_newDiv);
    }
    //Cloning Function
    //Validation
//submit function
$(document).on("click", 'input[type="checkbox"]', function() {
    jQuery(this).siblings(":checked").removeAttr('checked');
});

var result = {};
var dependants;
var dep_counter = 0;
jQuery('#submit').click(function(){
    jQuery('.dependant').each(function(k, v){
        dep_counter++
        dependants = {};
        result['dependant'+dep_counter] = [dependants];
        dependants['relationship'] = $(v).find('.relationship:checked').val();
    });
    var jsonData = JSON.stringify(result);
    console.log(jsonData);
});
});

and the HTML:

<div id="dependant-1" class="dependant">
    <div id="label">relationship:</div> <div id="relation-group-1"></div>
</div>

<button id="clone">clone</button>
<button id="submit">submit</button>
  • 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-17T08:05:02+00:00Added an answer on June 17, 2026 at 8:05 am

    See this updated fiddle : http://jsfiddle.net/EEd7c/7/

    Comment this line : $clonedDiv.find('input').val('');

    Also set dep_counter = 0; on submit button click..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is actually a three-part question, which I'll explain below, but the questions are:
Simple question - what does this actually do? var oq = (ObjectQuery<TEntity>)L2EQuery; return ExecuteFirstorDefault<TEntity>(oq,
I have seen code like this (actually seeing another person type it up): catch
I understand that 2 options are available: Non-persistent Persistent But what does this actually
This is actually a non-critical question, but I get this warning most of the
This is actually a continuation of a previous question: Spline on multiple factors in
I orginally asked this question and at the time I was grasping at straws.
Okay this is my first post here so please forgive me if i mess
This is in Oracle. I'm having an issue that I'm not sure can actually
Could someone explain in layman terms what this actually does? XmlTextReader textReader = new

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.