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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:39:14+00:00 2026-05-22T16:39:14+00:00

Is it possible? I want a user to post an array full of 1-5

  • 0

Is it possible?
I want a user to post an array full of 1-5 pieces of data.

At first there would be only one text field on show, but on clicking a ‘plus’ icon next to it, it would create another text field below it for more user input.

I would also want to have a delete icon next to text boxes 2-5, to remove them if necessary.

My JQuery knowledge is limited, and I can work out how to append text boxes to a list, but not to keep track of them/delete them. Ideally I would also want to pass them as an array to php, so I can easily loop through them.

<input type="text" size="15" maxlength="15" name="1"><img src="add.png" onclick="add();">
<!-- Below is hidden by default, and each one shows on click of the add image -->
<input type="text" size="15" maxlength="15" name="2"><img src="delete.png" onclick="delete(2);">
<input type="text" size="15" maxlength="15" name="3"><img src="delete.png" onclick="delete(3);">
<input type="text" size="15" maxlength="15" name="4"><img src="delete.png" onclick="delete(4);">
<input type="text" size="15" maxlength="15" name="5"><img src="delete.png" onclick="delete(5);">
  • 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-22T16:39:15+00:00Added an answer on May 22, 2026 at 4:39 pm

    jQuery clone() is very handy for this. A small example how it could be done (working example on jsfiddle)

    <ul>
        <li><input type="text" name="textbox[]" /></li>
    </ul>
    <input type="button" id="addTextbox" value="Add textbox" />
    <script type="text/javascript">
    $(function(){
        $('#addTextbox').click(function(){
            var li = $('ul li:first').clone().appendTo($('ul'));
    
            // empty the value if something is already filled in the cloned copy
            li.children('input').val('');
            li.append($('<button />').click(function(){
                li.remove();
                // don't need to check how many there are, since it will be less than 5.
                $('#addTextbox').attr('disabled',false);
            }).text('Remove'));
    
            // disable button if its the 5th that was added
            if ($('ul').children().length==5){
                $(this).attr('disabled',true);
            }
        }); 
    });
    
    </script>
    

    For the server-side part, you could then do a foreach() loop through the $_POST[‘textbox’]

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

Sidebar

Related Questions

Is it possible to extend user's session expiration time in CI. What I want
I have a situation here there are two models User,Posts Now I want to
Possible Duplicate: Redirect with POST data Is it possible for a script to redirect
I want to use jQuery ajaxForm to post data to an AsyncController to fire
As much as possible I want to avoid unnecessary duplication of code. In my
I want to trigger javascript alert using PHP. Is it possible I want to
I'm not sure if this is possible but I want to see objects created
Hey i dont know if that is possible but i want to set a
I'm new to Django, and I'm not sure what I want is possible: I
I want to ask wether it's possible to develop a J2ME application for Nokia

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.