Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Multiple Phone number form"
Bootstrap 3.3.0 Snippet by
downtap
3.3.0
jQuery
Preview
HTML
CSS
JS
View Full Screen
Forked from
Fork
Fork this
Parent
1.0K
 
0 Fav
Post to Facebook
Tweet this
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.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="page-header"> <h3>Phone Numbers</h3> </div> <form class="form-horizontal" style="max-width:450px;"> <div class="form-group"> <label class="col-sm-2 control-label">Phone</label> <div class="col-sm-10"> <div class="phone-list"> <div class="input-group phone-input"> <span class="input-group-btn"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false" style="width:150px"><span class="type-text">Type</span> <span class="caret"></span></button> <ul class="dropdown-menu" role="menu"> <li><a class="changeType" href="javascript:;" data-type-value="phone">Home</a></li> <li><a class="changeType" href="javascript:;" data-type-value="fax">Mobile</a></li> <li><a class="changeType" href="javascript:;" data-type-value="mobile">Business</a></li> </ul> </span> <input type="hidden" name="phone[1][type]" class="type-input" value="" /> <input type="text" name="phone[1][number]" class="form-control" placeholder="+1 (999) 999 9999" /> </div> </div> <button type="button" class="btn btn-success btn-sm btn-add-phone"><span class="glyphicon glyphicon-plus"></span> Add Phone</button> </div> </div> </form> <hr> </div>
.phone-input{ margin-bottom:8px; }
$(function(){ $(document.body).on('click', '.changeType' ,function(){ $(this).closest('.phone-input').find('.type-text').text($(this).text()); $(this).closest('.phone-input').find('.type-input').val($(this).data('type-value')); }); $(document.body).on('click', '.btn-remove-phone' ,function(){ $(this).closest('.phone-input').remove(); }); $('.btn-add-phone').click(function(){ var index = $('.phone-input').length + 1; $('.phone-list').append(''+ '<div class="input-group phone-input">'+ '<span class="input-group-btn">'+ '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false" style="width:150px"><span class="type-text">Type</span> <span class="caret"></span></button>'+ '<ul class="dropdown-menu" role="menu">'+ '<li><a class="changeType" href="javascript:;" data-type-value="phone">Phone</a></li>'+ '<li><a class="changeType" href="javascript:;" data-type-value="fax">Fax</a></li>'+ '<li><a class="changeType" href="javascript:;" data-type-value="mobile">Mobile</a></li>'+ '</ul>'+ '</span>'+ '<input type="text" name="phone['+index+'][number]" class="form-control" placeholder="+1 (999) 999 9999" />'+ '<input type="hidden" name="phone['+index+'][type]" class="type-input" value="" />'+ '<span class="input-group-btn">'+ '<button class="btn btn-danger btn-remove-phone" type="button"><span class="glyphicon glyphicon-remove"></span></button>'+ '</span>'+ '</div>' ); }); });
Related:
See More
Template
Vue Now UI Kit PRO
462.2K
45
login-form
170.4K
18
Login Form
141.9K
51
Contact Form
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76