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
"Payment form with total preview"
Bootstrap 3.0.0 Snippet by
hdindi
3.0.0
jQuery
Preview
HTML
JS
View Full Screen
Forked from
Fork
Fork this
Parent
1.1K
 
0 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.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"> <div class="col-sm-12"> <legend>Mr. Sosa:</legend> </div> <!-- panel preview --> <div class="col-sm-5"> <h4>Add payment:</h4> <div class="panel panel-default"> <div class="panel-body form-horizontal payment-form"> <div class="form-group"> <label for="concept" class="col-sm-3 control-label">Concept</label> <div class="col-sm-9"> <input type="text" class="form-control" id="concept" name="concept"> </div> </div> <div class="form-group"> <label for="description" class="col-sm-3 control-label">Description</label> <div class="col-sm-9"> <input type="text" class="form-control" id="description" name="description"> </div> </div> <div class="form-group"> <label for="amount" class="col-sm-3 control-label">Amount</label> <div class="col-sm-9"> <input type="number" class="form-control" id="amount" name="amount"> </div> </div> <div class="form-group"> <label for="status" class="col-sm-3 control-label">Status</label> <div class="col-sm-9"> <select class="form-control" id="status" name="status"> <option>Paid</option> <option>Unpaid</option> </select> </div> </div> <div class="form-group"> <label for="date" class="col-sm-3 control-label">Date</label> <div class="col-sm-9"> <input type="date" class="form-control" id="date" name="date"> </div> </div> <div class="form-group"> <div class="col-sm-12 text-right"> <button type="button" class="btn btn-default preview-add-button"> <span class="glyphicon glyphicon-plus"></span> Add </button> </div> </div> </div> </div> </div> <!-- / panel preview --> <div class="col-sm-7"> <h4>Preview:</h4> <div class="row"> <div class="col-xs-12"> <div class="table-responsive"> <table class="table preview-table"> <thead> <tr> <th>Concept</th> <th>Description</th> <th>Amount</th> <th>Status</th> <th>Date</th> </tr> </thead> <tbody></tbody> <!-- preview content goes here--> </table> </div> </div> </div> <div class="row text-right"> <div class="col-xs-12"> <h4>Total: <strong><span class="preview-total"></span></strong></h4> </div> </div> <div class="row"> <div class="col-xs-12"> <hr style="border:1px dashed #dddddd;"> <button type="button" class="btn btn-primary btn-block">Submit all and finish</button> </div> </div> </div> </div> </div>
function calc_total(){ var sum = 0; $('.input-amount').each(function(){ sum += parseFloat($(this).text()); }); $(".preview-total").text(sum); } $(document).on('click', '.input-remove-row', function(){ var tr = $(this).closest('tr'); tr.fadeOut(200, function(){ tr.remove(); calc_total() }); }); $(function(){ $('.preview-add-button').click(function(){ var form_data = {}; form_data["concept"] = $('.payment-form input[name="concept"]').val(); form_data["description"] = $('.payment-form input[name="description"]').val(); form_data["amount"] = parseFloat($('.payment-form input[name="amount"]').val()).toFixed(2); form_data["status"] = $('.payment-form #status option:selected').text(); form_data["date"] = $('.payment-form input[name="date"]').val(); form_data["remove-row"] = '<span class="glyphicon glyphicon-remove"></span>'; var row = $('<tr></tr>'); $.each(form_data, function( type, value ) { $('<td class="input-'+type+'"></td>').html(value).appendTo(row); }); $('.preview-table > tbody:last').append(row); calc_total(); }); });
Related:
See More
Template
Now UI Kit PRO
464.9K
45
login-form
171.1K
18
Login Form
142.4K
51
Contact Form
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76