"Bootstrap Price Calculator"
Bootstrap 4.0.0 Snippet by tieusuquay79

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.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="price-box"> <div class="row"> <div class="col-sm-6"> <form class="form-horizontal form-pricing" role="form"> <div class="price-slider"> <h4 class="great">Giá mỗi vé</h4> <span>Minimum 50 tickets is required</span> <div class="col-sm-12"> <div id="slider_amirol"></div> </div> </div> <div class="price-slider"> <h4 class="great">Gói dịch vụ</h4> <span>Please choose one</span> <input name="sliderVal" type="hidden" id="sliderVal" value='0' readonly="readonly" /> <input name="vip" type="hidden" id="vip" value='vipbac' readonly="readonly" /> <div class="btn-group btn-group-justified"> <div class="btn-group btn-group-lg"> <button type="button" class="btn btn-primary btn-lg btn-block vip active-vip selected-vip" id='vipbac'>VIP Bạc</button> </div> <div class="btn-group btn-group-lg"> <button type="button" class="btn btn-primary btn-lg btn-block vip" id='vipvang'>VIP Vàng</button> </div> </div> </div> <hr class="style"> <div class="form-group"> <div class="col-sm-12"> <a class="btn btn-success btn-lg btn-block" href="#">Xem gói dịch vụ <span class="glyphicon glyphicon-chevron-right"></span></a> </div> </div> </div> <div class="col-sm-6"> <div class="price-form"> <div class="form-group"> <div class="row"> <div class="col-sm-6"> <label for="amount_amirol" class="control-label">Giá mỗi vé (vnđ): </label> <span class="help-text">Hiển thị trên website Sansukien.com</span> </div> <div class="col-sm-6"> <input type="hidden" id="amount_amirol" class="form-control"> <!-- <p class="price lead" id="total"></p> --> <input class="price lead" name="totalprice" type="text" id="total" disabled="disabled" style="" /> </div> </div> </div> <div class="form-group"> <div class="row"> <div class="col-sm-6"> <label for="amount_amirol" class="control-label">Phí dịch vụ (vnđ): </label> <span class="help-text"><span class="help-percent">6%</span> + 10,000 (áp dụng trên mỗi vé)</span> </div> <div class="col-sm-6"> <input type="hidden" id="amount_amirol" class="form-control"> <!-- <p class="price lead" id="totalpricesv"></p> --> <input class="price lead" name="totalpricesv" type="text" id="totalpricesv" disabled="disabled" style="" /> </div> </div> </div> <div class="form-group"> <div class="row"> <div class="col-sm-6"> <label for="amount_amirol" class="control-label">Bạn nhận lại (vnđ): </label> <span class="help-text">Áp dụng trên mỗi vé</span> </div> <div class="col-sm-6"> <input type="hidden" id="amount_amirol" class="form-control"> <!-- <p class="price lead" id="totalpricelast"></p> --> <input class="price lead" name="totalpricelast" type="text" id="totalpricelast" disabled="disabled" style="" /> </div> </div> </div> <div style="margin-top:30px"></div> <hr class="style"> <div class="form-group"> <div class="col-sm-12"> <a class="btn btn-primary btn-lg btn-block" href="#">Liên hệ <span class="glyphicon glyphicon-chevron-right"></span></a> </div> </div> </div> </form> </div> <p class="text-center" style="padding-top:10px;font-size:12px;color:#2c3e50;font-style:italic;">Created by <a href="https://toantruong.me" target="_blank">Toan Truong</a></p> </div> </div> </div> <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
body { padding-top: 60px; } .price-box { margin: 0 auto; background: #E9E9E9; border-radius: 10px; padding: 40px 15px; /*width: 500px;*/ } .ui-widget-content { border: 1px solid #bdc3c7; background: #e1e1e1; color: #222222; margin-top: 4px; } .ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 7.2em; height: 2.7em; cursor: default; margin: 0 -40px auto !important; text-align: center; line-height: 30px; color: #FFFFFF; font-size: 12px; } .ui-slider .ui-slider-handle .glyphicon { color: #FFFFFF; margin: 0 1px; font-size: 11px; opacity: 0.7; } .ui-corner-all { border-radius: 20px; } .ui-slider-horizontal .ui-slider-handle { top: -.9em; } .ui-state-default, .ui-widget-content .ui-state-default { border: 1px solid #f9f9f9; background: #3498db; } .ui-slider-horizontal .ui-slider-handle { margin-left: -0.5em; } .ui-slider .ui-slider-handle { cursor: pointer; } .ui-slider a, .ui-slider a:focus { cursor: pointer; outline: none; } .price, .lead p { font-weight: 600; font-size: 32px; display: inline-block; line-height: 60px; border:0; width: 245px; } h4.great { background: #00ac98; margin: 0 0 25px -60px; padding: 7px 15px; color: #ffffff; font-size: 18px; font-weight: 600; border-radius: 5px; display: inline-block; -moz-box-shadow: 2px 4px 5px 0 #ccc; -webkit-box-shadow: 2px 4px 5px 0 #ccc; box-shadow: 2px 4px 5px 0 #ccc; } .total { border-bottom: 1px solid #7f8c8d; /*display: inline; padding: 10px 5px;*/ position: relative; padding-bottom: 20px; } .total:before { content: ""; display: inline; position: absolute; left: 0; bottom: 5px; width: 100%; height: 3px; background: #7f8c8d; opacity: 0.5; } .price-slider { margin-bottom: 70px; } .price-slider span { font-weight: 200; display: inline-block; color: #7f8c8d; font-size: 13px; } .form-pricing { background: #ffffff; padding: 20px; border-radius: 4px; } .price-form { background: #ffffff; margin-bottom: 10px; padding: 20px; border: 1px solid #eeeeee; border-radius: 4px; /*-moz-box-shadow: 0 5px 5px 0 #ccc; -webkit-box-shadow: 0 5px 5px 0 #ccc; box-shadow: 0 5px 5px 0 #ccc;*/ } .form-group { margin-bottom: 0; } .form-group span.price { font-weight: 200; display: inline-block; color: #7f8c8d; font-size: 14px; } .help-text { display: block; margin-top: -10px; margin-bottom: 10px; color: #737373; /*position: absolute;*/ /*margin-left: 20px;*/ font-weight: 200; /*text-align: right;*/ width: 188px; } .help-percent { color: #cc3333; } .price-form label { font-weight: 200; font-size: 21px; } .ui-slider-range-min { background: #2980b9; } .active-vip, .active-term { background: #cc3333; } /* HR */ hr.style { margin-top: 0; border: 0; border-bottom: 1px dashed #ccc; background: #999; }
// JavaScript Document var p = { 0: "Miễn phí", 1: "50K", 2: "100K", 3: "150K", 4: "200K", 5: "250K", 6: "300K", 7: "350K", 8: "400K", 9: "450K", 10: "500K", 11: "550K", 12: "600K", 13: "650K", 14: "700K", 15: "750K", 16: "800K", 17: "850K", 18: "900K", 19: "950K", 20: "1.000K", 21: "1.100K", 22: "1.200K", 23: "1.300K", 24: "1.400K", 25: "1.500K", 26: "1.600K", 27: "1.700K", 28: "1.800K", 29: "1.900K", 30: "2.000K", }; var t = { 0: "0", 1: "50000", 2: "100000", 3: "150000", 4: "200000", 5: "250000", 6: "300000", 7: "350000", 8: "400000", 9: "450000", 10: "500000", 11: "550000", 12: "600000", 13: "650000", 14: "700000", 15: "750000", 16: "800000", 17: "850000", 18: "900000", 19: "950000", 20: "1000000", 21: "1100000", 22: "1200000", 23: "1300000", 24: "1400000", 25: "1500000", 26: "1600000", 27: "1700000", 28: "1800000", 29: "1900000", 30: "2000000", } var obj = { 'vipbac' : '0.06', 'vipvang' : '0.05', }; var svcharge = '10000'; $(document).ready(function() { $("#total").val("0"); $("#slider_amirol").slider({ range: "min", animate: true, min: 0, max: 30, step: 1, slide: function(event, ui) { update(1,ui.value); //changed calcualtePrice(ui.value); } }); $('.vip').on('click',function(event) { var id = $(this).attr('id'); $('.vip').removeClass('selected-vip'); $(this).addClass('selected-vip'); $(".vip").removeClass("active-vip"); $(this).addClass("active-vip"); $('#vip').val(id); calcualtePrice() }); //$('.term').on('click',function(event) { //var id = $(this).attr('id'); //$('.term').removeClass('selected-term'); // $(this).addClass('selected-term'); //$(".term").removeClass("active-term"); //$(this).addClass("active-term"); //$('#term').val(id); // calcualtePrice() //}); update(); calcualtePrice(); }); function update(slider,val) { if(undefined === val) val = 0; var amount = p[val]; $('#sliderVal').val(val); $('#slider_amirol a').html('<label><span class="glyphicon glyphicon-chevron-left"></span> '+amount+' <span class="glyphicon glyphicon-chevron-right"></span></label>'); } function calcualtePrice(val){ if(undefined === val) val = $('#sliderVal').val(); var vip = $('#vip').val(); //var term = obj[vip][$('#term').val()]; var viptype = obj[vip]; //var totalPrice = t[val]*term; var totalPrice = t[val]; //alert(totalPrice); var totalsvcharge = Math.round((totalPrice)*(viptype)); var totalpricesv = 0; var totalpricelast = 0; if (totalsvcharge > 0) { totalpricesv = parseInt((totalsvcharge)) + parseInt(svcharge);; totalpricelast = Math.round((totalPrice)-(totalpricesv)); } $('.help-percent').html((viptype * 100) + '%'); $("#total").val(totalPrice.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.')); $("#totalpricesv").val(totalpricesv.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.')); $("#totalpricelast").val(totalpricelast.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.')); }

Related: See More


Questions / Comments: