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
"input US order form"
Bootstrap 3.0.0 Snippet by
maizovietnam
3.0.0
jQuery
input
Preview
HTML
JS
View Full Screen
Fork
Fork this
6.2K
 
4 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"> <table id="myTable" class=" table order-list"> <thead> <tr> <td>Thông tin sản phẩm</td> </tr> </thead> <tbody> <tr> <td class="col-sm-2"> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-tag"></i></span> <input id="product.name" type="text" class="form-control" name="product.name" placeholder="Tên sản phẩm"> </div> </td> <td class="col-sm-2"> <div class="input-group"> <span class="input-group-addon"><i class=" glyphicon glyphicon-link"></i></span> <input id="product.link" type="text" class="form-control" name="product.link" placeholder="Link sản phẩm"> </div> </td> <td class="col-sm-2"> <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-plus"></i></span> <input id="product.quantity" type="text" class="form-control" name="product.quantity" placeholder="Số lượng"> </div> <td class="col-sm-2"> <div class="input-group"> <label class="input-group-btn"> <span class="btn btn-primary"> Upload hình ảnh<input type="file" style="display: none;" multiple> </span> </label> <input type="text" class="form-control" readonly> </div> </td> <td class="col-sm-2"><a class="deleteRow"></a> </td> </tr> </tbody> <tfoot> <tr> <td colspan="5" style="text-align: left;"> <input type="button" class="btn btn-lg btn-block " id="addrow" value="Thêm sản phẩm" /> </td> </tr> <tr> </tr> </tfoot> </table> </div>
$(document).ready(function () { var counter = 0; $("#addrow").on("click", function () { var newRow = $("<tr>"); var cols = ""; cols += '<td><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-tag"></i></span><input id="product.name" type="text" class="form-control" name="product.name' + counter + '" placeholder="Tên sản phẩm"></div></td>'; cols += '<td><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-link"></i></span><input id="product.link" type="text" class="form-control" name="product.link' + counter + '" placeholder="Link sản phẩm"></div></td>'; cols += '<td><div class="input-group"><span class="input-group-addon"><i class="glyphicon glyphicon-plus"></i></span><input id="product.quantity" type="text" class="form-control" name="product.quantity' + counter + '" placeholder="Số lượng"></div></td>'; cols += '<td><div class="input-group"><label class="input-group-btn"><span class="btn btn-primary">Upload hình ảnh<input type="file" style="display: none;" multiple></span></label><input type="text" class="form-control" name="product.file' + counter + '" readonly></div></td>'; cols += '<td><input type="button" class="ibtnDel btn btn-md btn-danger " value="Xóa"></td>'; newRow.append(cols); $("table.order-list").append(newRow); counter++; }); $("table.order-list").on("click", ".ibtnDel", function (event) { $(this).closest("tr").remove(); counter -= 1 }); }); $(function() { // We can attach the `fileselect` event to all file inputs on the page $(document).on('change', ':file', function() { var input = $(this), numFiles = input.get(0).files ? input.get(0).files.length : 1, label = input.val().replace(/\\/g, '/').replace(/.*\//, ''); input.trigger('fileselect', [numFiles, label]); }); // We can watch for our custom `fileselect` event like this $(document).ready( function() { $(':file').on('fileselect', function(event, numFiles, label) { var input = $(this).parents('.input-group').find(':text'), log = numFiles > 1 ? numFiles + ' files selected' : label; if( input.length ) { input.val(log); } else { if( log ) alert(log); } }); }); }); function calculateRow(row) { var price = +row.find('input[name^="price"]').val(); } function calculateGrandTotal() { var grandTotal = 0; $("table.order-list").find('input[name^="price"]').each(function () { grandTotal += +$(this).val(); }); $("#grandtotal").text(grandTotal.toFixed(2)); }
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76