seiyria / bootstrap-slider

A slider control for Bootstrap 3 & 4.
http://seiyria.github.io/bootstrap-slider/
Other
3k stars 1.14k forks source link

How to format value for input #939

Closed tejashapani closed 4 years ago

tejashapani commented 4 years ago

Hello,

I would like to know that if it's possible to format the value for hidden input?

For example, on demo: https://seiyria.com/bootstrap-slider/#example-1 When we slide, it formats the tooltip like "Current value: 8". But it sets hidden input field value to "8" only.

I would like to format the hidden field value to something like $8. Though tooltip value is updated but i am not able to set hidden field value to $8.

Here is my sample code: var slider = new Slider("#medium_extra_test", { step: 1, min: 1, max: 2000, tooltip: "show", value: 1000, formatter: function (value) { return "$" + addCommas(value) ; } }); slider.on("slide", function (sliderValue) { // other operation on slide });

Is it possible anyhow?

Thanks Tejas

seiyria commented 4 years ago

I can't say I particularly understand why you'd want a hidden slider, but there's no reason for it to not work. Can you share a jsfiddle?

tejashapani commented 4 years ago

Here is the jsfiddle: https://jsfiddle.net/z7e2k3rv/

I am not sure why tooltip is not showing on jsfiddle example. but i have code to format the value like $1,000.

I would like to get the same value of slider with formatting like $1,000 when user submit the form.

And that is why i would like to format the hidden field value so that i can get formatted value on form data.

seiyria commented 4 years ago

This is not really a use case I think we have the intent to support. I would recommend using a normal hidden input if this is what you need. As an idea, you could use a real slider and update the value of the hidden input when it updates.