Modified Slider UI with 2 hidden inputs and showing value in html.

Modified Slider UI with 2 hidden inputs and showing value in html.

I've made a modified version for Range Slider UI . You can use 2 hidden Inputs. In each hidden input is 1 value and values is also in html with live changing. Here is the code if anyone wants it , you can use it.If you know a better solution for this, don't hesitate and post it to comments.Together we can make it better. I am begginer so take a look at it.

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI Slider - Range slider</title>
  6. <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
  7. <script src="../../../jquery-1.7.2.min.js"></script>
  8. <script src="../../ui/jquery.ui.core.js"></script>
  9. <script src="../../ui/jquery.ui.widget.js"></script>
  10. <script src="../../ui/jquery.ui.mouse.js"></script>
  11. <script src="../../ui/jquery.ui.slider.js"></script>
  12. <link rel="stylesheet" href="../demos.css">
  13. <style>
  14. #demo-frame > div.demo { padding: 10px !important; }
  15.   #text_price {
  16.    padding-bottom:5px;
  17.   }
  18. </style>
  19. <script>
  20. $(function() {
  21. $( "#slider-range" ).slider({
  22. range: true,
  23. min: 0,
  24. max: 500,
  25. values: [ 75, 300 ],
  26. slide: function( event, ui ) {
  27. $( "#amount_1" ).val( ui.values[ 0 ] );
  28.         $( "#amount_2" ).val( ui.values[ 1 ] );
  29.         $( "#amount_1_show" ).text( ui.values[ 0 ] );
  30.         $( "#amount_2_show" ).text( ui.values[ 1 ] ); 
  31. }
  32. });
  33.     $( "#amount_1" ).val( $( "#slider-range" ).slider( "values", 0 ) );
  34.     $( "#amount_2" ).val( $( "#slider-range" ).slider( "values", 1 ) );
  35.     
  36.     $( "#amount_1_show" ).text( $( "#slider-range" ).slider( "values", 0 ) );
  37.     $( "#amount_2_show" ).text( $( "#slider-range" ).slider( "values", 1 ) );

  38. });
  39. </script>
  40. </head>
  41. <body>

  42. <div class="demo" style="width:300px;position:absolute;font-size:12px;">

  43.   <div id="text_price">
  44.   Price range:
  45.   <span id="amount_1_show" style="color:#f6931f; font-weight:bold;"></span> -
  46.   <span id="amount_2_show" style="color:#f6931f; font-weight:bold;"></span>
  47.   </div>
  48.   
  49.   <input type="hidden" id="amount_1" style="border:0; color:#f6931f; font-weight:bold;" />
  50.   <input type="hidden" id="amount_2" style="border:0; color:#f6931f; font-weight:bold;" />

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

  52. </div>

  53. </body>
  54. </html>