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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:10:57+00:00 2026-05-17T16:10:57+00:00

I have a form generated dynamically with the method .append() of jQuery. I can

  • 0

I have a form generated dynamically with the method .append() of jQuery.
I can add any number of new input, textbox, cmbbox, etc…

But the problem is that when I do the sumbit of the form, the PHP target does not receive the new input added, but just the vars connected to the input already in the form before the append().

Any ideas?

The javascript:

$("#button").live('click',function add(){
   $("#list").append(
       '<li style="height:20px;">'
    +'<input type="text" class="text" id="prova" name="prova[]" value="prova">'+ 
       '</li>'
   );
});

The Html:

<input type="submit" id="button" value="Add input">
<form name = "form" id="form" action="post.php" method="POST">
   <ul style="width:670px;padding:0px 0px 30px 0px" id="list">
   </ul>
   <input type="submit" id="submit" value="Submit">
</form>

The PHP:

<?php
  print_r($_POST);
?>
  • 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-17T16:10:58+00:00Added an answer on May 17, 2026 at 4:10 pm

    Problem 1:

    Your #button should not be of type submit, since you just want to use it to add to the form and not submit the form. So you should have:

    <input type="button" id="button" value="Add input">
    

    Problem 2:

    You are overwriting your variables. The name is the variable sent with the form, so each input addition must have a new name, or the variable must be an array.

    Additionally, you can’t have more than one element with the same id.

    The simplest way to solve this is to make prova an array by using the form prova[]:

    $("#button").live('click',function() {
       $("#list").append(
           '<li style="height:20px;">' +
             // Removed repetitive ID and made prova an array
           '<input type="text" class="text" name="prova[]" value="prova"></li>'
       ); 
    });
    

    jsFiddle example

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

Sidebar

Related Questions

I have a question. Currently this form will be dynamically generated. Example, <form method=POST>
i have a form in which there can be multiple radio buttons generated dynamically
I have a form that is dynamically generated, and has dynamically generated id's (and
I have a method that creates a form in my controller: ... sbReturn.Append(String.Format(<p id='planSetupAddNewEffectiveDate'>));
I have the following code generated dynamically. It can be just one, two, three
i have a form that is generated dynamically. the plan is to generate it,
I have an asp.net url path which is being generated in a web form,
I have a form like this: <form name=mine> <input type=text name=one> <input type=text name=two>
I have a form with many input fields. When I catch the submit form
I have a button on a form that is dynamically spawning a select list,

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.