24.2 C
New York
Wednesday, August 10, 2022

Simple Add remove input fields dynamically using jquery with Bootstrap

- Advertisement -

In this tutorial, I am going to show you how to add remove input fields dynamically in your form using jquery. In this simple example, i give you to add multiple input fields with remove button that way you can remove field if you don’t require. In this example i use bootstrap also because layout become pretty good.

In this example, Simply i added two click event of jquery as listed bellow:

1.add-more Class: On “.add-more” class that way we can write jquery append code.

2.remove Class: On “.remove” class that way we can remove input field.

I also added “copy” class div, that will be append after “after-add-more” class that way you can also modify easily on “copy” class like you want to change text or icon etc. It is pretty simple example and you can easily customize this example.

You have to create two file one for generate script code of add more input fields, and second file for getting value of dynamic field value.

So, let’s create both files, after finish this example you will find bellow output. you can check on demo for dynamic add more input fields.



<html lang="en">


<title>Bootstrap Jquery Add More Field Example</title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">



<div class="container">

<div class="panel panel-default">

<div class="panel-heading">Bootstrap Jquery Add More Field Example</div>

<div class="panel-body">

<form action="action.php" >

<div class="input-group control-group after-add-more">

<input type="text" name="addmore[]" class="form-control" placeholder="Enter Name Here">

<div class="input-group-btn">

<button class="btn btn-success add-more" type="button"><i class="glyphicon glyphicon-plus"></i> Add</button>




<!-- Copy Fields -->

<div class="copy hide">

<div class="control-group input-group" style="margin-top:10px">

<input type="text" name="addmore[]" class="form-control" placeholder="Enter Name Here">

<div class="input-group-btn">

<button class="btn btn-danger remove" type="button"><i class="glyphicon glyphicon-remove"></i> Remove</button>







<script type="text/javascript">

$(document).ready(function() {


var html = $(".copy").html();











In this PHP file you can get value of multiple input fields this way:





- Advertisement -

Related Articles


Please enter your comment!
Please enter your name here

Latest Articles