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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:17:30+00:00 2026-05-17T23:17:30+00:00

In this fiddle you see a table with a select-field where you should select

  • 0

In this fiddle you see a table with a select-field where you should select a name.
Below there are 5 input-fields where one could type in some text and 3 input-fields which are set to readonly.

I wanted to ask whether there is a way to add table cells dynamically when clicking on the button. The result should like this fiddle. The id should be incremented by i+.
I tried cloning the code, but could’t figure out how to do increment the id of the cloned input-field. The only input-fields I do not want to clone are the readonly input-fields.

Do you have an example code or a link you would recommend? A hint to start would be helpful as well.

I’ve been searching the net already, but wasn’t able to find something.

  • 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-05-17T23:17:31+00:00Added an answer on May 17, 2026 at 11:17 pm

    Here is the code you ask (i added an id to the button to target it easy)

      $('#add').click(function(){
    
        $(this)
            .closest('table')
            .find('tr td:first-child:not(:has([readonly]))')
            .each(function(){
                var $this = $(this);
                $this
                    .clone()
                    .each(function(){
                        var $inp = $(':input',this);
                        var id = $inp.attr('id');
                        var idwithoutnum = id.replace(/([0-9]+)$/,'');
                        var maxId = $(':input[id^='+idwithoutnum+']:last').attr('id');
                        var idnum = parseInt(/([0-9]+)$/.exec(maxId)) + 1;
                        var newid = id.replace(/([0-9]+)$/,idnum);
                        $inp.attr('id', newid);
                        alert(newid); // remove this line
                    })
                    .insertAfter($this
                                 .closest('tr')
                                 .find('td:last')
                                );
        });
    });
    

    example at http://jsfiddle.net/fMZDd/7/

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

Sidebar

Related Questions

Please see this fiddle (the result window should be made large). When one of
Fiddle me this: http://jsfiddle.net/TrySpace/QZMP6/17/ After editing the input field, the html updates on each
I have a table as below; <table id=mytable cellpadding=0 cellspacing=0> <tr> <td>&nbsp;</td> <td><input type=text
Please see this fiddle I want the scrolling div stop following when left div
Here is my fiddle: http://jsfiddle.net/jamesbrighton/wxWgG/4/ HTML: <div> <p class=click>Click 1</p> <p>This should be ignored</p>
See this fiddle: http://jsfiddle.net/uqJHf/ I have set the first column to show up with
Please see this fiddle for my situation. Essentially, I have a floating span which
This is my code (please see this fiddle ): HTML <div id=container> <span id=left>Left
Here's my current fiddle: http://jsfiddle.net/UjAQf/79/ My target table design is this: But I'm having
I created this fiddle so that you can see what i am trying to

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.