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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:58:29+00:00 2026-05-26T14:58:29+00:00

so I have been researching this all morning- and I’m pretty sure the code

  • 0

so I have been researching this all morning- and I’m pretty sure the code is correct but to explain I am trying to include a table in the dynamically generated input, so need the tr/td in there. I have reviewed the html/wrap/append etc. functions to no avail… 🙁

See the comment there for the full script but really this is the meat of it. Any help would be greatly appreciated.

I tried the wrap and document writes but it doesn’t like it. what am I missing???

$(document).ready(function() {
    $('#btnAdd').click(function() {
        var num     = $('.clonedInput').length; // how many "duplicatable" input     fields we currently have
        var newNum  = new Number(num + 1);      // the numeric ID of the new input     field being added
        //http://charlie.griefer.com/blog/2009/09/17/jquery-dynamically-adding-    form-elements/
        // create the new element via clone(), and manipulate it's ID using newNum     value
        var newElem = $('#input' + num).clone().attr('id', 'input' +     newNum).wrap('<td />');
        // manipulate the name/id values of the input inside the new element
        newElem.children(':first').attr('id', 'name' + newNum).attr('name', 'name'     + newNum).val('');
        newElem.children(':second').attr('id', 'amt' + newNum).attr('name', 'amt'     + newNum).val('');
        newElem.children(':third').attr('id', 'value' + newNum).attr('name',     'value' + newNum).val('');
        newElem.children(':fourth').attr('id', 'test' + newNum).attr('name',     'test' + newNum).val('');
        // insert the new element after the last "duplicatable" input field
        document.write("<tr>");
        $('#input' + num).after(newElem);
        document.write("</tr>");
  • 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-26T14:58:30+00:00Added an answer on May 26, 2026 at 2:58 pm

    Using document.write() in $(document).ready() will wipe out your existing document and start a new document. I rather doubt that is what you intend (especially since you appear to be trying to add rows to an existing table).

    You need to use jQuery functions for inserting new elements into the DOM instead of document.write(). There are many jQuery calls for manipulating the DOM. You can see some of them here. I’d guess that you want calls like append() or after().

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

Sidebar

Related Questions

I've been researching this all morning and have decided that as a last-ditch effort,
I have been researching all over the internet about this, and unfortunately cannot find
I have been researching this issue pretty extensively and cannot seem to find an
I have been researching this for a while but got no convinced answer. From
Okay I am newer to python and have been researching this problem but I
I've been researching a solution to this all week and while there have been
I've been researching this all day but I haven't found anything about the rootViewController
this may seem obvious, but I've been researching this all night to no avail.
I have been researching and trying to learn the proper method to accomplish this.
I have been researching this for a few hours and I feel that I

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.