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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:51:38+00:00 2026-05-12T11:51:38+00:00

Edit: I fixed the problem by just starting from scratch. Sorry to waste y’alls

  • 0

Edit: I fixed the problem by just starting from scratch. Sorry to waste y’alls time. Please vote to close if you feel so inclined.

I’m having trouble getting the actual data in a form to submit when the input fields are added via javascript. The fields show up, and in the right place, but when I do a var_dump( fieldname) on the server side, nothing is showing up. Inspecting with Live HTTP headers tells me that the browser isn’t trying to submit the dynamically added form fields.

Do I need to somehow “attach” my dynamically created form inputs to the form?

My code:

HTML

<form id="att_form" method="post" name="add_attachments" enctype="multipart/form-data" action="#">
<-- below input to prove form submits, just not the dyn added elements -->
<input name="data[one]" type="text" />
<div id="add_fields"></div>
<input type="submit" />
</form>

Javascript

function addFormField()
{
 var id = 1;
 var htm = "<p id='row" + id + "'><input type='text' size='20' name='txt[]' id='txt" + id + "' /></p>";
 $("#add_fields".append( htm );
}

When I submit the form, my input named data[one] shows up as a POSTd value, but those added with addFormField() do not. They show up, in the HTML, at the correct place, but don’t POST. Do I need to append the element as a child to my form element to get it to submit?

I’ve seen Submit form input fields added with javascript which is where I got the idea of appending the data specifically to the form child, but that will require some restructuring of my CSS. So, I’m hoping that it’s something simple I can do in the above code.

Thanks in advance!

edit: fixed the typos, but still not working. I’ve decided to use the library free JS method discussed in the SO link above, as that works fine. Thanks for the help though!

  • 1 1 Answer
  • 2 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-12T11:51:38+00:00Added an answer on May 12, 2026 at 11:51 am

    There were a lot of typos in your code. For example, you didn’t close the selector tag for jquery.

    You put
    $("#add_fields".append( htm );

    Should have been
    $("#add_fields").append( htm );

    Notice the missing parantheses.

    But I believe your problem lies mainly in how you’re trying to access the values through PHP. I just put your source in a test page and it all works if you access the values correctly.

    <?php
    foreach ($_REQUEST['txt'] as $printme) 
        echo $printme."<br/>";
    ?>
    

    The above source works fine.

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

Sidebar

Related Questions

Edit : The bug that caused this problem has been fixed. The @version tag
Edit: Creating a new module in the same VSMacros project fixed the problem. The
[EDIT: FIXED! The problem appears to be having an invisible VideoView overlaying my GLSurfaceView
EDIT: Fixed most of the problem (but not too sure why). Check the bottom
Edit: closing anchor fixed. This issue exists when testing on the following browsers: Google
EDIT: I have fixed all but two warnings now, so thank you all for
EDIT : As of 2012-06-11 this bug has been finally fixed! https://bugs.webkit.org/show_bug.cgi?id=35981#c1 I have
EDIT: The issue underneath is fixed, GO TO EDIT2 in this post. I have
[SOLVED]: Applying proper list iteration procedure fixed problem. (Shown below) I currently have a
I just ran into to strange problem, I have a custom tableview cell with

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.