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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:13:42+00:00 2026-06-12T15:13:42+00:00

Within a Project form, a user can clone any specific task — this is

  • 0

Within a Project form, a user can clone any specific task — this is working fine. I now need to replace the copied task’s index ID (which is a time stamp) with a new time stamp. My current code only replaces a single div.

How can I replace all form input/label field IDs with a timestamp? I current do a find() and then replace.

Any ideas greatly appreciated!

$(function() {
  $('form').on('click', '.clone-task', function(event) {
    event.preventDefault();
    var time = new Date().getTime();
    var taskCopy = $(this).parents(".dupForm").clone();
    $("#dupTask").append(workoutCopy);
    var attributes = taskCopy.find('input').attr('name').replace(/\[\d+]/g, time);
      alert(attributes);
    });
 });

Task Form (ruby-on-rails):

 <fieldset>
 <div class="field">
 <b><%= f.label :name, "Major Task" %></b> | 
 <%= f.text_field :name, :placeholder => "task name" %>
 <%= f.hidden_field :_destroy %>
 <%= link_to "remove", '#', class: "remove_fields" %>
 </div>

 <div class="field">
 <%= f.label :time_start, "Scheduled Time" %><br />
 <%= f.time_select :time_start, {:ampm => true, :minute_step => 15} %>
 </div>
 <div class="field">
 <%= f.label :task_duration, "Task Duration(mins)" %>
 <%= f.number_field :task_duration, size: 3 %>
 </div>
 <b>Add Supporting Actions to Your Task</b> 
 <%= f.fields_for :activities do |builder| -%>
 <%= render 'activity_fields', f: builder %>
 <% end %>
 </div>
 <%= link_to_add_fields "Add Action", f, :activities %>
 </fieldset> 
  • 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-12T15:13:44+00:00Added an answer on June 12, 2026 at 3:13 pm

    jQuery attr() method allows you to use a function as argument which will act as a loop to process all matched elements.

    taskCopy.find('input').attr('name', function( idx, name){
        return name.replace(/\[\d+]/g, time);
    });
    

    API refrence: http://api.jquery.com/attr/

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

Sidebar

Related Questions

I have a fully working Setup project within Visual Studio 2008 that takes inputs
Possible stupid question: let's say I have two apps contained within one project. Can
I am working on implementing Zend Framework within an existing project that has 2
How can I set the System.Windows.Controls.DatePicker control as used within a Silverlight project to
Let me provide some context: I created a standalone project call Contact Form. Within
The project I'm currently working on is a form designer (Silverlight Application) wherein the
I'm trying to copy and past a form within a project using Visual Studio.
i am working on a project that displays posts type within a radius entered
I have Aptana installed within Eclipse. I'm working on a project with the dojo
I had integrated in app billing within my project in order to sell managed

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.