11

I am using ionRangeslider in one of my forms to show the range of tips.

How can I update the value on submit button click so that when next time page loads, it shows the slider with that particular updated value?

HTML code

<input type="text" class="exampleslider" id="exampleslider" name="tips">

And Calling to ionRangeSlider via js

$('.exampleslider').ionRangeSlider({
  from: 0,
  to: 100,
  min: 0,
  grid: true,
  grid_num: 10,
  step: 10,
  postfix: '%',
});

Input is given name tips through which I want to set its value via database.

joshweir
  • 5,427
  • 3
  • 39
  • 59
Shashank Bhatt
  • 717
  • 1
  • 11
  • 28

2 Answers2

20
 var instance = $(id).data("ionRangeSlider");

 instance.update({
   from: 10 //your new value
 });
joshweir
  • 5,427
  • 3
  • 39
  • 59
sajad khajeh
  • 311
  • 2
  • 8
1

I have a slider with custom values.

In this case, the indices should be used as from to values instead of actual values.

For example, the slider was initialized with this array:

[0, 100, 500, 1000, 2000, 10000]

Let update its handles to be on 500 and 2000:

var data = $('#' + id).data("ionRangeSlider");

data.update({
   from: 2,
     to: 4 
 });
Yuriy N.
  • 4,936
  • 2
  • 38
  • 31