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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:52:53+00:00 2026-05-31T17:52:53+00:00

The problem in my case is I can dynamically add / remove input boxes,

  • 0

The problem in my case is I can dynamically add / remove input boxes, but the problem is when I manually add a set of input box and remove button instead of press add button to create one, it can not remove it.

Is it possible to have 3 sets of input boxes but 2 remove buttons?

Thank you for any kind of help.

JSFiddle

enter image description here

    <script>
$(document).ready(function() {
    $("#add").click(function() {
        var intId = $("#buildyourform div").length + 1;
        var label = $("<label>Field Name</label>");
        var labelType = $("<label>Field Type</label>");
        var labelReq = $("<label>Require</label>");
        var labelTag = $("<label>Tag</label>");
        var fieldWrapper = $("<div class=\"fieldwrapper\" id=\"field" + intId + "\"/>");
        var fName = $("<input type=\"text\" name=\"inputName[]\" class=\"required\" />");
        var fTag = $("<input type=\"text\" name=\"inputTag[]\" class=\"required\" />");
        var fReq = $("<select class=\"fieldtype\"><option value=\"checkbox\">Checked</option><option value=\"1\">Yes</option><option value=\"0\">No</option></select>");
        var fType = $("<select class=\"fieldtype\"><option value=\"checkbox\">Checked</option><option value=\"textbox\">Text</option><option value=\"textarea\">Paragraph</option></select>");
        var removeButton = $("<input type=\"button\" class=\"remove\" value=\"Remove\" />");
        removeButton.click(function() {
            $(this).parent().remove();
        });

        fieldWrapper.append(label);
        fieldWrapper.append(fName);
        fieldWrapper.append('<br>');
        fieldWrapper.append(labelType);
        fieldWrapper.append(fType);
        fieldWrapper.append('<br>');
        fieldWrapper.append(labelReq);
        fieldWrapper.append(fReq);
        fieldWrapper.append('<br>');
        fieldWrapper.append(labelTag);
        fieldWrapper.append(fTag);
        fieldWrapper.append('<br>');
        fieldWrapper.append(removeButton);
        $("#buildyourform").append(fieldWrapper);
    });
});

</script>



</head>
<body>

<form id="config" method="post" action="config.php" >
<fieldset id="buildyourform">
    <legend>Build your own form!</legend>


<!-- I manually create  a set of input box here -->

        <div class="fieldwrapper" id="field1"><label>Field Name</label><input type="text" name="inputName[]" class="required"><br><label>
Field Type</label><select class="fieldtype">
<option value="checkbox">Checked</option><option value="textbox">Text</option><option value="textarea">Paragraph</option></select><br><label>Require</label>
<select class="fieldtype"><option value="checkbox">Checked</option>
<option value="1">Yes</option><option value="0">No</option></select><br><label>
Tag</label><input type="text" name="inputTag[]" class="required"><br><input type="button" class="remove" value="Remove"></div>


<!-- I manually create a set of input box here -->




    <input type="text" name="input[]" value="test">
</fieldset>
<input type="button" value="Add a field" class="add" id="add" />
<input type="submit" value="Submit">


</form>

</html>
  • 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-31T17:52:54+00:00Added an answer on May 31, 2026 at 5:52 pm

    Try setting the remove button actions when the document is loaded.

    Try it here or use the code below.

    <script>
    $(document).ready(function() {
        $('.remove').click(function(){
            $(this).parent().remove();
        });
    
        $("#add").click(function() {
            var intId = $("#buildyourform div").length + 1;
            var label = $("<label>Field Name</label>");
            var labelType = $("<label>Field Type</label>");
            var labelReq = $("<label>Require</label>");
            var labelTag = $("<label>Tag</label>");
            var fieldWrapper = $("<div class=\"fieldwrapper\" id=\"field" + intId + "\"/>");
            var fName = $("<input type=\"text\" name=\"inputName[]\" class=\"required\" />");
            var fTag = $("<input type=\"text\" name=\"inputTag[]\" class=\"required\" />");
            var fReq = $("<select class=\"fieldtype\"><option value=\"checkbox\">Checked</option><option value=\"1\">Yes</option><option value=\"0\">No</option></select>");
            var fType = $("<select class=\"fieldtype\"><option value=\"checkbox\">Checked</option><option value=\"textbox\">Text</option><option value=\"textarea\">Paragraph</option></select>");
            var removeButton = $("<input type=\"button\" class=\"remove\" value=\"Remove\" />");
            removeButton.click(function() {
                $(this).parent().remove();
            });
    
            fieldWrapper.append(label);
            fieldWrapper.append(fName);
            fieldWrapper.append('<br>');
            fieldWrapper.append(labelType);
            fieldWrapper.append(fType);
            fieldWrapper.append('<br>');
            fieldWrapper.append(labelReq);
            fieldWrapper.append(fReq);
            fieldWrapper.append('<br>');
            fieldWrapper.append(labelTag);
            fieldWrapper.append(fTag);
            fieldWrapper.append('<br>');
            fieldWrapper.append(removeButton);
            $("#buildyourform").append(fieldWrapper);
        });
    });
    
    </script>
    
    
    
    </head>
    <body>
    
    <form id="config" method="post" action="config.php" >
    <fieldset id="buildyourform">
        <legend>Build your own form!</legend>
    
    
    <!-- I manually create  a set of input box here -->
    
            <div class="fieldwrapper" id="field1"><label>Field Name</label><input type="text" name="inputName[]" class="required"><br><label>
    Field Type</label><select class="fieldtype">
    <option value="checkbox">Checked</option><option value="textbox">Text</option><option value="textarea">Paragraph</option></select><br><label>Require</label>
    <select class="fieldtype"><option value="checkbox">Checked</option>
    <option value="1">Yes</option><option value="0">No</option></select><br><label>
    Tag</label><input type="text" name="inputTag[]" class="required"><br><input type="button" class="remove" value="Remove"></div>
    
    
    <!-- I manually create a set of input box here -->
    
    
    
    
        <input type="text" name="input[]" value="test">
    </fieldset>
    <input type="button" value="Add a field" class="add" id="add" />
    <input type="submit" value="Submit">
    
    
    </form>
    
    </html>​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem getting this test case to work. Can anyone point me
I have a problem.. I am working on timezone on PHP but In case
I'll rewrite a different question of mine, because the problem case somewhat changed: If
I Have two problem in this Case : I want to pass a JSON
Is there any solution to overcome case-sensitive problem for contains method. I have code
While playing with NLP I've been encountered with little problem: switch(var1) { case Variant1_1:
A toy-case for my problem: I have a numpy array of size, say, 1000:
So I have this problem with strings and switch-case, and I'll try to keep
I have a problem with my activity. This is my onCreate: case NORMAL: game
I would like to implement a thread pool in Java, which can dynamically resize

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.