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 8377271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:37:43+00:00 2026-06-09T15:37:43+00:00

I’m developing a registration website and there’s a part where I need to add

  • 0

I’m developing a registration website and there’s a part where I need to add people. What I do is when they click on a text bellow the name and last name of the person another two fields (asking the name and the person once again, so it’s a copy of the one above) appear. This I do it using the clone() method. So let’s say the name and last name are inside a div with a class called: “information”. And the <p> that adds the extra div when contained has an id called: “add”. Like this:

<div class="information">
<label for="name">Name</label>
<input type="text" name="name[]"> //it's an array because there's gonna be probably more than one (if they click the "add" text)
<label for="last_name">Last Name</label>
<input type="text" name="last_name[]">
</div>
<p id="add">Add another person</p>

My javascript (jquery) is the following:

$('#add').click(function(){
    $('.information').clone().insertAfter('.information');
});

The problem with this is that when you click the add text it copies the first div (and if you wrote something on it, it copies it too). So how can I solve that. Is there any other way to do it? Plus, is there any easy way to make a button to disappear an “information” div (in case the user regrets how many people he wants to add).

Any recommendation is well received.
Thanks in advance.

EDIT:
Sorry guys. There’s something important that I forgot to say. The information class is only displayed if the user click a checkbox (because there’s the possibility that they don’t wish to add any other person.
So, here is the code for the checkbox:

HTML (above the information class):

<input type="checkbox" id="companion" />Companion

JQuery:

$("#companion").click(function() {
     $(".information").toggle();
     if ($('#companion').is(":checked")) {
        $('#add').show();
     }
     else {
        $('.companion').hide();
        $('.companion').removeAttr('checked');
    }
});

I clarify this because I tried the examples that you guys show me but when I click the checkbox the information div does not show up.
I should have mention this on my original post. I really sorry.

  • 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-09T15:37:45+00:00Added an answer on June 9, 2026 at 3:37 pm

    I’d change it just slightly and do it like this jsFiddle example.

    This allows you to add people and remove any new one you add while always leaving just the first person.

    HTML

    <div id="information">
    <label for="name">Name</label>
    <input type="text" name="name[]"> 
    <label for="last_name">Last Name</label>
    <input type="text" name="last_name[]">
    </div>
    <p id="add">Add another person</p>​
    

    jQuery

    $('#add').click(function() {
        $('#information').clone().find("input:text").val("").end().append('<span class="remove">remove</span>').removeAttr('id').insertBefore('#add');
    
    });
    $('body').on('click', '.remove', function() {
        $(this).parent('div').remove();
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT

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.