"Dynamic Form Fields"
Bootstrap 3.2.0 Snippet by tudo75

<link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <h3>Nice Multiple Form Fields</h3> <input type="hidden" name="count" value="1" /> <div id="fields"> <input autocomplete="off" class="form-control" id="field1" name="prof1" type="text" placeholder="Type something (it has typeahead too)" data-provide="typeahead" data-items="8" data-source='["Aardvark","Beatlejuice","Capricorn","Deathmaul","Epic"]'/> <button id="b1" class="btn btn-info add-more"><i class="glyphicon glyphicon-plus"></i></button> </div> <p><small>Press + to add another form field</small></p> </div> </div>
.form-control { width: 25%; display: inline; } .add-more { padding: 6px 12px; vertical-align: top; }
$(document).ready(function(){ var next = 1; $(".add-more").click(function(e){ e.preventDefault(); var addto = "#field" + next; next = next + 1; var newIn = '<br /><br /><input autocomplete="off" class="form-control" id="field' + next + '" name="field' + next + '" type="text" data-provide="typeahead" data-items="8">'; var newInput = $(newIn); $(addto).after(newInput); $("#field" + next).attr('data-source',$(addto).attr('data-source')); $("#count").val(next); }); });

Related: See More


Questions / Comments: