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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:25:16+00:00 2026-06-12T12:25:16+00:00

I made several input field boxes with the following code: <script type=’text/javascript’>//<![CDATA[ $(window).load(function(){ $(‘.add’).click(function(){

  • 0

I made several input field boxes with the following code:

<script type='text/javascript'>//<![CDATA[ 
    $(window).load(function(){
        $('.add').click(function(){
            par_id=$(this).parent().attr('id');
            count=$("#"+par_id+"> input").length;
            id=par_id.toString();
            $(this).parent().append("<br/><input type='text' id='"+id+"'>");
        });
    });//]]>  
</script>

I’m using the aforementioned code in order to create input fields that can dynamically add new fields.

This code creates multiple identical form ids, but I want it to create multiple identical form names so I can output it altogether using the foreach command.

Now I want to output the input data into a PHP using this

<?php
    foreach($_POST['formid'] as $value) {
        echo "$value <br />";
    }
?>

What I want to ask is that the foreach command will only output data from the form name, but the javascript code I am using creates more input forms by the form id, not the form name.

So I need a code that will create more input boxes with form name, not form id!

I’m not sure how to modify the original code, since I got it from another website.

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-12T12:25:17+00:00Added an answer on June 12, 2026 at 12:25 pm

    You simply need to add a name attribute to the code which is inserted by the javascript function.

    Original:

    $(this).parent().append("<br/><input type='text' id='"+id+"'>");
    

    Ammended:

    $(this).parent().append("<br/><input type='text' name='yourinputname' id='"+id+"'>");
    

    EDIT: Just and afterthought…

    If the ID serves no purpose and only the name attribute is required, the majority of this code is unnecessary and can be reduced to the following.

    <script type='text/javascript'>//<![CDATA[ 
        $(window).load(function(){
            $('.add').click(function(){
                $(this).parent().append("<br/><input type='text' name='yourinputname');
            });
        });//]]>  
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made a Service that reads in several databases and load it in to
Quick question about CI. I have a view with a form, several text input
I am attempting to capture when a text input field's value is changed. I
I have several divs, which are made automatically by php script. Each div have
I have a very simple example jsfiddle : HTML: <input type=text/> <input type=text value=aaa/>
I have a javascript code (i) that write several <div><a href=...></a></div> inside the <div
I'd to add a wrapper around a row with jquery. I've made several attempts
I've come across an intriguing problem. I have an application made of several assemblies.
I have several libraries made by myself (a geometry library, a linked list library,
I have made modifications to several example OpenCV projects within Android, however I am

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.