1

I want to implement a Bootstrap slider where the values increment by 0.01. Also, I should be able to specify the range of values; for example, the user can only select values between 4 and 12, and moving the slider increases the values in the increments of 0.01.

Razor/HTML

<input id="inputRateOfInterest" type="text" />

jQuery

<script src="~/lib/jquery/dist/jquery.js"></script>
<script type="text/javascript">
    $("#inputRateOfInterest").scroll({
        precision: 2,
        value: 8.10
    });
</script>

Output I am not seeing any slider in the output. I am simply getting a textbox where I am able to enter text.

I am new to Bootstrap. I referred to some links that gave me some idea, but I wasn't able to go further. I might be missing something.

  • If you're seeing a text box, it means you're not initializing the slider correctly. Fix that first. – Seiyria Jan 16 '18 at 13:04
  • I referenced the code from http://seiyria.com/bootstrap-slider/ See Example 9 –  Jan 16 '18 at 17:39
  • Referencing it isn't good enough. Please make a jsfiddle or something if you're having trouble initializing it. As I stated, a text box means it's not being initialized properly. For other related errors, check the javascript console. – Seiyria Jan 16 '18 at 17:59

1 Answers1

1

U might have missed out relative js files.

Example

<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script type="text/javascript" src='https://rawgit.com/seiyria/bootstrap-slider/master/dist/bootstrap-slider.js'></script>
<link rel="stylesheet" type="text/css" href="https://rawgit.com/seiyria/bootstrap-slider/master/dist/css/bootstrap-slider.css">
<link rel="stylesheet" type="text/css" href="http://seiyria.com/bootstrap-slider/css/bootstrap.min.css">

<h3>Bootstrap Slider Example</h3>
<p>
<input type="text" onchange="RGBChange()" class="span2" value="" data-slider-min="4" data-slider-max="12" data-slider-step="0.01" data-slider-value="5" data-slider-id="GC" id="G" data-slider-tooltip="hide" data-slider-handle="round" />
</p>

<input id="val" type="text"></input>

<script>
var RGBChange = function() {
 $("#val").val(g.getValue());
};

var g = $('#G').slider()
  .on('slide', RGBChange)
  .data('slider');
</script>

here is a working fiddle for your reference. u can have a look at bootstrap slider examples in Git.

user8535883
  • 56
  • 1
  • 3