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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:40:24+00:00 2026-05-26T07:40:24+00:00

I add input text box dynamically and trying to pass values using POST method

  • 0

I add input text box dynamically and trying to pass values using POST method but everytime I submit the form, I only receive the first value.

<script type="text/javascript">

function add_ele() {

    // For Internet Explorer
        try {
            el = document.createElement("<input type='text' name='cat[]' >");
        }
        // For other browsers
        catch (e) {
            el = document.createElement('input');
            el.setAttribute('type', 'text');
            el.setAttribute('name', 'cat[]');
        }

    document.getElementById('cate').appendChild(el);
    }
</script>



<form action='submit.php' method='POST' enctype='multipart/form-data'>
<div id='cate' style='width:100px'>
<input type='text' name='cat[]' value='kjkj'>
</div>
</form>
<a href='#' onClick=\"return add_ele()\">Add Another</a>

Submit page:

$p_cat = $_POST['cat'];
foreach ($p_cat as $p_cate ) {

echo "$p_cate . <br>";
}

Someone please guide.

  • 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-26T07:40:25+00:00Added an answer on May 26, 2026 at 7:40 am

    If that is your complete code, you’re not setting the <input>‘s value attribute, so there’s nothing to submit. Here’s a modified (and cleaned up) example:

    <script type="text/javascript">
    
        function addElement() {
            var  input = document.createElement('input');
            input.setAttribute('type', 'text');
            input.setAttribute('name', 'cat[]');
            input.setAttribute('value', 'some value');
            document.getElementById('cate').appendChild(input);
    
            // We need to return false so the href isn't followed.
            return false;
        }
    
    </script>
    
    <form action="submit.php" method='POST' enctype="multipart/form-data">
        <div id="cate" style="width: 100px">
            <input type="text" name="cat[]" value="kjkj">
        </div>
    </form>
    
    <a href="#" onclick="return addElement()">Add Another</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a form a text box is created dynamically by clicking on add button
<html> <body> <form name=Upload enctype=multipart/form-data method=post> Filename: <INPUT type=file id=submit> <INPUT type=button id=send value=Upload>
i want to post dynamically generated multiple text box using php by foreach loop.
I have a form where users can add input fields with jQuery. <input type="text"
I am adding HTML input controls on the page dynamically via a add text
I have the following dynamically created HTML block: <form class=standard settingsPage method=post enctype=multipart/form-data name=account
I have created a custom component. I add a dynamic input text box to
I'd like to add a DIV above an input box (textbox) without changing the
How can I add an input form in an Excel sheet. I want to
I'm trying to add a class to the selected radio input and then remove

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.