Domanda

I am using a jquery ui price range slider . And I a have option for selecting the currency . The problem is if a user select a different currency the range slider is still same . I want to change the slider range value in different currency upon changing the currency . right now it is only show range in dollar , I want when user will select euro , the range will changed to euro Here is what I am doing

<title>jQuery UI Slider - Range slider</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#slider-range" ).slider({
      range: true,
      min: 0,
      max: 500,
      values: [ 75, 300 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
      " - $" + $( "#slider-range" ).slider( "values", 1 ) );
  });
  </script>
</head>
<body>
<select name=currency class=f15>
                    <option value=USD selected>USD</option>
                    <option value=BDT >BDT</option>
                    </select> &nbsp; 
<p>
  <label for="amount">Price range:</label>
  <input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;">
</p>

<div id="slider-range"></div>

Fiddle

È stato utile?

Soluzione

Try this,

Demo

$(function() {
    $('select').change(function(){
     $( "#amount" ).val( $('select').val() + $( "#slider-range" ).slider( "values", 0 ) +
      " - "+ $('select').val() + $( "#slider-range" ).slider( "values", 1 ) );
    })
    $( "#slider-range" ).slider({
      range: true,
      min: 0,
      max: 500,
      values: [ 75, 300 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( $('select').val() + ui.values[ 0 ] + " - "+ $('select').val() + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( $('select').val() + $( "#slider-range" ).slider( "values", 0 ) +
      " - "+ $('select').val() + $( "#slider-range" ).slider( "values", 1 ) );
  });

HTML:

<select name=currency class=f15>
                    <option value="$" selected>USD</option>
                    <option value="&#2547;" >BDT</option>
                    </select> &nbsp; 
<p>
  <label for="amount">Price range:</label>
  <input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;">
</p>

<div id="slider-range"></div>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top