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
"Bootstrap Pricing Slider (Donations) test"
Bootstrap 3.1.0 Snippet by
contin16
3.1.0
Preview
HTML
View Full Screen
Forked from
Fork
Fork this
Parent
886
 
0 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.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"> <form class="form-horizontal form-pricing" role="form"> <div class="price-slider"> <h4 class="great">Amount</h4> <span>Minimum $1 is required</span> <div class="col-sm-12"> <div id="slider"></div> </div> </div> <div class="price-form"> <div class="form-group"> <label for="amount" class="col-sm-6 control-label">Amount ($): </label> <span class="help-text">Please choose your amount</span> <div class="col-sm-6"> <input type="hidden" id="amount" class="form-control"> <p class="price lead" id="amount-label"></p> <span class="price"></span> </div> </div> <hr class="style"> </div> <div class="form-group"> <div class="col-sm-12"> <button type="submit" class="btn btn-primary btn-lg btn-block">Proceed <span class="glyphicon glyphicon-chevron-right pull-right" style="padding-right: 10px;"></span></button> </div> </div> <div class="form-group"> <div class="col-sm-12"> <img src="http://amirolahmad.github.io/bootstrap-pricing-slider/images/payment.png" class="img-responsive payment" /> </div> </div> </form> </div> </div> <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script> <script> $(document).ready(function() { $("#slider").slider({ animate: true, value:1, min: 1, max: 1000, step: 1, slide: function(event, ui) { update(1,ui.value); //changed } }); //Added, set initial value. $("#amount").val(0); $("#duration").val(0); $("#amount-label").text(0); $("#duration-label").text(0); update(); }); //changed. now with parameter function update(slider,val) { //changed. Now, directly take value from ui.value. if not set (initial, will use current value.) var $amount = slider == 1?val:$("#amount").val(); var $duration = slider == 2?val:$("#duration").val(); /* commented $amount = $( "#slider" ).slider( "value" ); $duration = $( "#slider2" ).slider( "value" ); */ $total = "$" + ($amount * $duration); $( "#amount" ).val($amount); $( "#amount-label" ).text($amount); $( "#duration" ).val($duration); $( "#duration-label" ).text($duration); $( "#total" ).val($total); $( "#total-label" ).text($total); $('#slider a').html('<label><span class="glyphicon glyphicon-chevron-left"></span> '+$amount+' <span class="glyphicon glyphicon-chevron-right"></span></label>'); $('#slider2 a').html('<label><span class="glyphicon glyphicon-chevron-left"></span> '+$duration+' <span class="glyphicon glyphicon-chevron-right"></span></label>'); } </script>
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76