DEV Community

Robert Look
Robert Look

Posted on

Add Remove Multiple Input Fields Dynamically With Jquery - Step By Step

we learn to add/remove input fields dynamically with jquery. this form submit is very useful many times bulk data needs to be submitted at once. If you have a requirement to add/remove multiple input fields dynamically with jquery, the input group makes it easy for you. we will easily Example from scratch how dynamically add/remove multiple input fields and submit to the database with jquery.

Add Remove Multiple Input Fields Dynamically With Jquery - Step By Step

<h2>Add Remove Multiple Input Fields Dynamically With Jquery - phpcodingstuff.com</h2>
<form method="post" action="submit.php">

    <div class="form-group fieldGroup">
        <div class="input-group">
            <input type="text" name="name[]" class="form-control" placeholder="Enter name"/>
            <div class="input-group-addon"> 
                <a href="javascript:void(0)" class="btn btn-success addMore"><span class="glyphicon glyphicon glyphicon-plus" aria-hidden="true"></span> Add</a>
            </div>
        </div>
    </div>

    <input type="submit" name="submit" class="btn btn-primary" value="SUBMIT"/>

</form>

<!-- copy of input fields group -->
<div class="form-group fieldGroupCopy" style="display: none;">
    <div class="input-group">
        <input type="text" name="name[]" class="form-control" placeholder="Enter name"/>
        <div class="input-group-addon"> 
            <a href="javascript:void(0)" class="btn btn-danger remove"><span class="glyphicon glyphicon glyphicon-remove" aria-hidden="true"></span> Remove</a>
        </div>
    </div>
</div>


Enter fullscreen mode Exit fullscreen mode

Top comments (0)