karenpommeroy / rangeslide.js

Lightweight customizable range slider with labels (but without jQuery)
MIT License
9 stars 4 forks source link

Set rangeslide value with a form #5

Open FrantisekPavlicek opened 4 years ago

FrantisekPavlicek commented 4 years ago

Hi, thanks for your rangeslider, great work! I'm using the rangeslider with time data in a free mode and I stumbled upon a use case, where I would like to allow the user to select date in a form with an input type date and then on submitting this form I want to move the rangeslider thumb to the selected date. After the form is submitted, I can obtain the selected date with

var dateControl = document.querySelector('input[type="date"]');
var val = dateControl.valueAsDate;

And now I would like to do something like

rangeslider.setValue('2020-07-09')

Is there any way to pass the value from the form to the rangeslider, so that the thumb moves to the desired position? The setValue function only allows me to set the value based on an index in the data variable, but I don't see any option, how to move the thumb to a specific date value.

Thanks for your answer in advance.

karenpommeroy commented 4 years ago

There isn't such an option as far as I can remember. Later on today I'll try to see what it would take to implement one.

czw., 9 lip 2020 o 08:43 František Pavlíček notifications@github.com napisał(a):

Hi, thanks for your rangeslider, great work! I'm using the rangeslider with time data in a free mode and I stumbled upon a use case, where I would like to allow the user to select date in a form with an input type date and then on submitting this form I want to move the rangeslider thumb to the selected date. After the form is submitted, I can obtain the selected date with

var dateControl = document.querySelector('input[type="date"]'); var val = dateControl.valueAsDate;

And now I would like to do something like

rangeslider.setValue('2020-07-09')

Is there any way to pass the value from the form to the rangeslider, so that the thumb moves to the desired position? The setValue function only allows me to set the value based on an index in the data variable, but I don't see any option, how to move the thumb to a specific date value.

Thanks for your answer in advance.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/karenpommeroy/rangeslide.js/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWXQDKFSZ5M2YT4RMY343R2VRJVANCNFSM4OVI46DA .

-- Pozdrawiam, Marcin Karpiński