2016-10-20 2 views
0

내가 부트 스트랩 슬라이드를 사용하고, 당신은 지금 자신이 $ 1000처럼 보여주는, 여기 내가 가격의 형식을 변경할 수있는 방법 http://bootsnipp.com/snippets/2XQ2변경 가격 형식 - 부트 스트랩 가격 슬라이더

에서 코드를 찾을 수 있습니다.

저는 $ 1000 정도를 원하고 $ 150000 정도를 원합니다.

<script> 
    $(document).ready(function() { 
     $("#slider").slider({ 
      range: "min", 
      animate: true, 
      value:1, 
      min: 10000, 
      max: 300000, 
      step: 100, 
      slide: function(event, ui) { 
      update(1,ui.value); //changed 
      } 
     }); 

     //Added, set initial value. 
     $("#amount").val(0); 
     $("#amount-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(); 

    $total = "£" + ($amount * 10); 
    $("#amount").val($amount); 
    $("#amount-label").text($amount); 
    $("#total").val($total); 
    $("#total-label").text($total); 

    $('#spend').html('<label> '+$amount+' </label>'); 
    } 

</script> 

답변

0

당신은 그런 일 수행 할 수 있습니다 : 여기

는 문서입니다

function update(slider,val) { 
     var formatNumber = { 
     separador: ",", 
     sepDecimal: '.', 
     formatear:function (num){ 
      num +=''; 
      var splitStr = num.split('.'); 
      var splitLeft = splitStr[0]; 
      var splitRight = splitStr.length > 1 ? this.sepDecimal + splitStr[1] : ''; 
      var regx = /(\d+)(\d{3})/; 
      while (regx.test(splitLeft)) { 
      splitLeft = splitLeft.replace(regx, '$1' + this.separador + '$2'); 
      } 
      return this.simbol + splitLeft +splitRight; 
     }, 
     new:function(num, simbol){ 
      this.simbol = simbol ||''; 
      return this.formatear(num); 
     } 
     } 
    //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); 
    $total = formatNumber.new($total,"$"); 
    $("#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>'); 
    } 
+0

총계를 잘 고쳐 주셔서 감사합니다 ... 슬라이더 크기는 어떻습니까? 여전히 쉼표없이 표시 : ( – Atif

+0

'$ 총 = ($ 금액 * $ 기간); '.'후 $'$ amount = formatNumber.new ($ 금액);'. – Paplusc

+0

고마워요 Paplusc :) – Atif

0

mask의 플러그인을 jquery에서 사용할 수 있습니다. 이와 같이

:

$(‘.money’).mask(‘000,000,000,000,000.00’, {reverse: true}); 

(이것은 일례이다). https://igorescobar.github.io/jQuery-Mask-Plugin/

+0

그것은 JQuery와에서이 아니다 그것은 JQuery와 출신을 도와 – Alexis

+0

감사에서 플러그인,하지만 난 그렇게 많이하지 않다 Java에서 좋은 점 : (코드에서이 예제를 어디서 사용하면 좋을까요? – Atif