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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:03:06+00:00 2026-06-04T01:03:06+00:00

On the form, a customer can create multiple groups. Every group has the same

  • 0

On the form, a customer can create multiple groups. Every group has the same input fields. If customer clicks on ‘+ Additional Group’ then an additional group will be created dynamically via jQuery (The html is downloaded via an AJAX call).

Below is the sample html. Each ul tag is a group. In the group ul, each input field includes a group number field. Like this: foo_1, foo_2

current_group is a hidden field which keeps track of the total number of groups.

If add_group button has been clicked, jQuery will get the total number of groups from current_group and then additional group dynamically.

Is this how it should be done?

Also if a customer click on Submit button when they have finish Form – it may return back to same page because of Error Validation via PHP. I don’t want to loose dynamic html groups again. How can this be solved?

<h2> Group One </h2>
<ul class="Form">
    <li>
        <label>Foo</label>
        <select name='foo_1'>
                <option value='1'>One</option>
                <option value='2'>Two</option>
                <option value='3'>Three</option>
        </select>
    </li>
   <li>
        <label>Bar</label>
        <select name='bar_1'>
                <option value='car'>Car</option>
                <option value='bike'>Bike</option>
                <option value='van'>Van</option>
        </select>
    </li>
<ul>

<h2> Group Two </h2>
<ul class="Form">
    <li>
        <label>Foo</label>
        <select name='foo_2'>
                <option value='1'>One</option>
                <option value='2'>Two</option>
                <option value='3'>Three</option>
        </select>
    </li>
   <li>
        <label>Bar</label>
        <select name='bar_2'>
                <option value='car'>Car</option>
                <option value='bike'>Bike</option>
                <option value='van'>Van</option>
        </select>
    </li>
<ul>

<input type='hidden' id='current_group' value='2' />
<input type='button' id='add_group' value='+ Additional Group' />
  • 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-04T01:03:08+00:00Added an answer on June 4, 2026 at 1:03 am

    Well if the first set of HTML elements is there already, you can always use jQuery’s clone() to copy the elements instead of calling the server. You would need to find the elements and replace the names like you talked about.

    jQuery(".Form").clone().find("select").eq(0).prop("name", "foo_" + count).end().eq(1).prop("name", "bar_" + count).end().end().appendTo("#someElem"); 
    

    In a more readable format

    var count = 1;
    function addRow(){
        count++;
        var newFormElems = jQuery(".Form").clone();  //clone the form
        var selects = newFormElems.find("select");  //find the selects
        selects.eq(0).prop("name", "foo_" + count);  //rename first
        selects.eq(1).prop("name", "bar_" + count);  //rename second
        newFormElems.appendTo("#someElem");   //add to the page
    }
    

    Another way to redo the naming function which it increments the number:

    newFormElems.find("select").each( 
        function(){        
            this.name = this.name.replace(/^([^_]+_)(\d+)/, function(match,str,num){ return str + (parseInt(num,10)+1)});
        }
    );
    

    And what is the best way to deal with the dynamic forms? Well you can submit the data with Ajax or you have the php code write out form after the validation.

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

Sidebar

Related Questions

I want to put 2 fields on user registration form, /customer/account/create/. Those fields are
I want to know how I can create a folder via Oracle form Builder?
I have inherited a project, that provides an order form to a customer. The
Like many web applications (business) the customer wants a form that will search across
I want to add a new form to the edit customer page, so far
I am getting a textbox value from a form, i which the customer inputs
Form has the DoubleBuffered property (bool, inherited from Control). If this is set to
I have a form where users can enter data that ultimately would be used
I'm trying to create a good looking product order form with jquery skills. I
Time ago I created an application which has some buttons in the form. Now

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.