"Untitled"
Bootstrap 4.1.1 Snippet by eliaskorolev

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <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">Сумма</h4> <div class="col-sm-12"> <div id="slider"></div> </div> </div> <div class="price-slider"> <h4 class="great">Срок</h4> <div class="col-sm-12"> <div id="slider2"></div> </div> </div> <div class="price-form"> <div class="form-group"> <label for="amount" class="col-sm-6 control-label">Сумма: </label> <span class="help-text">Сколько хотите взять?</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> <div class="form-group"> <label for="duration" class="col-sm-6 control-label">Срок: </label> <span class="help-text">На какой срок?</span> <div class="col-sm-6"> <input type="hidden" id="duration" class="form-control"> <input type="hidden" id="duration1"> <p class="price lead" id="duration-label"></p> <span class="price"></span> </div> </div> <hr class="style"> <div class="form-group total"> <label for="total" class="col-sm-6 control-label"><strong>К возврату: </strong></label> <span class="help-text">(Сумма * процент в день по сроку/100)*кол.дней в месяце+сумма</span> <div class="col-sm-6"> <input type="hidden" id="total" class="form-control"> <p class="price lead" id="total-label"></p> <span class="price"></span> </div> </div> </div> </form> </div> </div> <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
body { padding-top: 50px; padding-bottom: 50px; } .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: 5.2em; height: 2.2em; cursor: default; margin: 0 -40px auto !important; text-align: center; line-height: 30px; color: #FFFFFF; font-size: 15px; } .ui-slider .ui-slider-handle .glyphicon { color: #FFFFFF; margin: 0 3px; font-size: 11px; opacity: 0.5; } .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; } 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: 32px; margin-bottom: 10px; color: #737373; position: absolute; /*margin-left: 20px;*/ font-weight: 200; text-align: right; width: 188px; } .price-form label { font-weight: 200; font-size: 21px; } img.payment { display: block; margin-left: auto; margin-right: auto } .ui-slider-range-min { background: #2980b9; } /* HR */ hr.style { margin-top: 0; border: 0; border-bottom: 1px dashed #ccc; background: #999; }
$(document).ready(function() { var slider1 = $("#slider").slider({ animate: true, value:1000, min: 1000, max: 500000, step: 1000, slide: function(event, ui) { update(1,ui.value); //changed } }); var slider2 = $("#slider2").slider({ animate: true, value:3, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); //Added, set initial value. $("#amount").val(1000); $("#duration").val('3 месяца'); $("#duration1").val(3); $("#amount-label").text(0); $("#duration-label").text('3 месяца'); 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:$("#duration1").val(); /* commented $amount = $( "#slider" ).slider( "value" ); $duration = $( "#slider2" ).slider( "value" ); */ if(slider == 1){ if($amount >= 1000 && $amount <= 30000){ $total = parseInt(($amount * 0.5/100)*90)+parseInt($amount); $("#duration-label").text('3 месяца'); $('#slider2 a').html('<label>3 месяца</label>'); $duration = 3; $('#slider a').html('<label>'+$amount+'</label>'); $("#slider2").slider({ animate: true, value:3, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); }else if($amount >= 30000 && $amount <= 50000){ $total = parseInt(($amount * 0.5/100)*120)+parseInt($amount); $("#duration-label").text('4 месяца'); $('#slider2 a').html('<label>4 месяца</label>'); $('#slider a').html('<label>'+$amount+'</label>'); $duration = 4; $("#slider2").slider({ animate: true, value:4, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); }else if($amount >= 50000 && $amount <= 100000){ $total = parseInt(($amount * 0.26/100)*183)+parseInt($amount); $("#duration-label").text('6 месяцев'); $('#slider2 a').html('<label>6 месяцев</label>'); $('#slider a').html('<label>'+$amount+'</label>'); $duration = 5; $("#slider2").slider({ animate: true, value:5, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); }else if($amount >= 100000 && $amount <= 500000){ $total = parseInt(($amount * 0.20/100)*365)+parseInt($amount); $( "#duration" ).val('1 год'); $("#duration-label").text('1 год'); $('#slider2 a').html('<label>1 год</label>'); $('#slider a').html('<label>'+$amount+'</label>'); $duration = 6; $("#slider2").slider({ animate: true, value:6, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); } }else{ if($duration == 3){ // $amount = 1000; // if($amount >= 1000 && $amount <= 30000){ // $total = parseInt(($amount * 0.5/100)*90)+parseInt($amount); $("#duration-label").text('3 месяца'); $('#slider2 a').html('<label>3 месяца</label>'); $('#slider a').html('<label>1000</label>'); $("#slider").slider({ animate: true, value:1000, min: 1000, max: 500000, step: 1000, slide: function(event, ui) { update(1,ui.value); //changed } }); $("#slider2").slider({ animate: true, value:3, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); // } }else if($duration == 4){ // $amount = 30000; // if($amount >= 30000 && $amount <= 50000){ // $total = parseInt(($amount * 0.5/100)*120)+parseInt($amount); $("#duration-label").text('4 месяца'); $('#slider a').html('<label>30000</label>'); $('#slider2 a').html('<label>4 месяца</label>'); $('#slider a').html('<label>30000</label>'); $("#slider").slider({ animate: true, value:30000, min: 1000, max: 500000, step: 1000, slide: function(event, ui) { update(1,ui.value); //changed } }); $("#slider2").slider({ animate: true, value:4, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); // } }else if($duration == 5){ // $amount = 50000; // if($amount >= 50000 && $amount <= 100000){ // $total = parseInt(($amount * 0.26/100)*183)+parseInt($amount); $("#duration-label").text('6 месяцев'); $('#slider a').html('<label>50000</label>'); $('#slider2 a').html('<label>6 месяцев</label>'); $("#slider").slider({ animate: true, value:50000, min: 1000, max: 500000, step: 1000, slide: function(event, ui) { update(1,ui.value); //changed } }); $("#slider2").slider({ animate: true, value:5, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); // } }else if($duration == 6){ // $amount = 100000; // if($amount >= 100000 && $amount <= 500000){ $("#slider").slider({ animate: true, value:100000, min: 1000, max: 500000, step: 1000, slide: function(event, ui) { update(1,ui.value); //changed } }); $("#slider2").slider({ animate: true, value:6, min: 3, max: 6, step: 1, slide: function(event, ui) { update(2,ui.value); //changed } }); // $total = parseInt(($amount * 0.20/100)*365)+parseInt($amount); // $( "#duration" ).val('1 год'); $("#duration-label").text('1 год'); $('#slider a').html('<label>100000</label>'); $('#slider2 a').html('<label>1 год</label>'); // } } } $( "#amount" ).val($amount); $( "#amount-label" ).text($amount); $( "#duration1" ).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>'); }

Related: See More


Questions / Comments: