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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:55:38+00:00 2026-06-17T23:55:38+00:00

I’m using simple clone plugin. This is the github page of that plugin. As

  • 0

I’m using simple clone plugin. This is the github page of that plugin.

As of now it generates input name like

user[projects][0][name]
user[projects][1][name]
user[projects][2][name]

Can anyone tell me how to generate name like

user[projects_name][0][1]
user[projects_name][1][1]
user[projects_name][2][1]

I have created a jsfiddle to show you demo.

http://jsfiddle.net/Viruthagiri/YLSdQ/1/

I think this is the function that generates the id.

// append a initial number to elements id, if options[:nested] true, also assign a initial number to the element name
  e.find("input, select").each(function(){
    var old_id = $(this).attr("id");
    $(this).attr("id", old_id+'_0');
    if(option.nested == true) {
      var old_name = $(this).attr("name");
      var reg = /\[\w*\]$/;
      var match = reg.exec(old_name);
      var new_name = old_name.substr(0, match.index) + "[0]" + match[0];
      $(this).attr("name", new_name);
    }
  })
$.fn.regenerate_names = function(number){
    $(this).find("input, select").each(function(){
      var old_name = $(this).attr("name");
      var old_number = old_name.match(/.*\[(\d+)\]/)[1];  // find the last match
      var old_number_index = old_name.lastIndexOf(old_number);
      var new_name = old_name.substring(0,old_number_index) + number + old_name.substring(old_number_index+1);
      $(this).attr("name", new_name);
    });
  };

Here is the full source code

  • 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-17T23:55:40+00:00Added an answer on June 17, 2026 at 11:55 pm

    I am pake007, the author of the plugin. I have updated the plugin to support your requirement.
    Please clone the newest version of simple-clone on github, and for your question, I think you can try the following code:

    <div class='project_group'>
      <input id="user_projects_name" name="user[projects_name][1]" type="text" /> 
    </div>
    
    $(".project_group").simple_clone({
      label: "Project Name ",
      label_colon: true,
      nested: true,
      start: 1
    });
    

    The new option “start” is used for setting the start of the first array index in the input name, default is 0.

    The above code will generate input names like:

    user[projects_name][1][1]
    user[projects_name][2][1]
    user[projects_name][3][1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display

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.