Hi i'm using this range slider: http://rangeslider.js.org/
I would like to know how to add decimal points on the output div like so: 1.000,000
Hi i'm using this range slider: http://rangeslider.js.org/
I would like to know how to add decimal points on the output div like so: 1.000,000
Sorry for jumping in, but I am actually having the same question...
The example goes from "0" to "100" - would like to know how to change it in a way that it goes from "0" to "100000" and displays "100.000" instead of "100000".
In addition would be great to know if it is possible to add a "€" sign?
Thanks a ton to everyone who can help!!!
http://codepen.io/andreruffert/pen/meeOav
HTML
<h1>Vertical orientation support</h1>
<input type="range" data-orientation="vertical">
<output></output>
Javascript:
var $element = $('input[type="range"]');
var $output = $('output');
function updateOutput(el, val) {
el.textContent = val;
}
$element
.rangeslider({
polyfill: false,
onInit: function() {
updateOutput($output[0], this.value);
}
})
.on('input', function() {
updateOutput($output[0], this.value);
});
CSS
output {
font-size: 2em;
padding: .3em;
}
I figure out a solution with the help of a friend. Make these changes where you call the function to start the slider.
This is how the code look originally:
var $element1 = $('#slider_range_1');
var $output1 = $('#output_1');
$element1
.rangeslider({
polyfill: false,
onInit: function() {
updateOutput($output1[0], this.value.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'));
}
})
.on('input', function() {
updateOutput($output1[0],parseInt(this.value).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'));
console.log(this.value);
});
The piece of code below formats the output and add the decimal points and dollar sign to it
.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,')
The code should look like this after you make the changes.
var $element1 = $('#slider_range_1');
var $output1 = $('#output_1');
$element1
.rangeslider({
polyfill: false,
onInit: function() {
updateOutput($output1[0], this.value.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'));
}
})
.on('input', function() {
updateOutput($output1[0],parseInt(this.value).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'));
console.log(this.value);
});