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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:40:21+00:00 2026-06-11T21:40:21+00:00

I am using this script with jquery for my dynamic add/remove input field: <script>

  • 0

I am using this script with jquery for my dynamic add/remove input field:

<script>
$(document).ready(function(){

var i = $('input').size() + 1;

$('#add').click(function() {
    $('<div><input type="text" class="field" name="dynamic[]" value="' + i + '" /></div>').fadeIn('slow').appendTo('.inputs');
    i++;
});

$('#remove').click(function() {
if(i > 1) {
    $('.field:last').remove();
    i--;
}
});

$('#reset').click(function() {
while(i > 2) {
    $('.field:last').remove();
    i--;
}
});

});
</script>

My input field code:

<a href="#" id="add">Add</a> | <a href="#" id="remove">Remove</a> | <a href="#" id="reset">reset</a>
<div class="inputs"><input type="text" name="dynamic[]" class="field" placeholder=""/></div>

So everything works fine with this code, but I can’t seem to figure out how to create more than one working box in the same webpage.

I tried adding numbers to the name field, (like dynamic2, dynamic3, etc) but it doesn’t do anything for me.

Is there a way to create another one of the same functioning input box, but with a different assigned name so I can POST it to PHP individually?

I am using this PHP for posting:

<?php
foreach($_POST['dynamic'] as $value) {
echo "$value <br />"; // change this to what you want to do with the data
}
?>

PHP posting works fine, but I can only do ONE input group at a time. I want to be able to do multiple on the same page.

I got the original script from this webpage:
http://papermashup.com/dynamically-add-form-inputs-and-submit-using-jquery/

Please help!

  • 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-11T21:40:22+00:00Added an answer on June 11, 2026 at 9:40 pm

    here is a jsFiddle implementation if doing the same for multiple blocks

    all you have to do is create multiple blocks (3 blocks are given in the example) in html and you are ready to go.

    in PHP you have to access it using

    <?php
        if(isset($_POST)){
            echo '<pre>';print_r($_POST['dynamic1']);echo '</pre>';
            echo '<pre>';print_r($_POST['dynamic2']);echo '</pre>';
            echo '<pre>';print_r($_POST['dynamic3']);echo '</pre>';
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this script below for loading a hidden div, inside another: $(document).ready(function(){ $(function()
After loading a PHP template (using jQuery's load function), this simple script won't make
Im using jquery 1.3.2 and this is the code: <script type=text/javascript> //<![CDATA[ jQuery(function(){ jQuery('.news_bullet
Hay, i'm using this script function preloader(images){ var i = 0; imageObj = new
Recently I've been looking at opening a tab using this script: $('.tofour').click(function() { //
I'm using this java script library to show ratings http://www.fyneworks.com/jquery/star-rating/#tab-Overview . I'm using below
I'm using Dynamic Drive's jQuery Context Menu script and I can get the context
i am using the code found here jQuery - dynamic div height <script type='text/javascript'>
I'm using this code to be able to generate an dynamic select: demo: http://www.erichynds.com/examples/jquery-related-selects
I'm trying to add validation to a dynamic input field. What I'm doing is

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.