Is there any way to allow a positive minimum and a negative maximum? I am trying to create the slider in log space (10^8-10-13) and want to show the exponent on the slider.
<input type="range" min="8" max='-13' value="1" step="-1" id="myRange" >
This currently reverts to the default max=100
value.
Or perhaps can I reverse the slider in some way? Any help would be much appreciated.
EDIT: Please remember I want the scale to be DECREASING from 8 to -13 (log space 10^8-10^-13).
EDIT: In IDL xr=[8,-13] (or R xlim=c(8,-13)). Note that the minimum value is a positive and the max is a negative number, and you can step between the two accordingly. I am asking for help with a workaround to create the same behaviour with the input type range.
This slider will be reversed: min(left) is 8 and max(right) is -13, i think this is what you wanted... and step=-1 don't works.
HTML:
<input type="range" min="-13" max="8" value="1" step="1" id="range"/>
css:
#range{
transform: rotateY(180deg);
}
Thx css!
You could simply switch the limits and multiply the value by -1
:
<input type="range" min="-8" max='13' value="1" step="1" id="slider" >
$('#slider').change(function(){
var val = -+($(this).val());
console.log(val);
});
If you'll need the value to be submitted, copy it to a hidden field, and use that on server-side instead of the original.
A live demo at jsFiddle.
Scale the slider from 0 to 21 with step=1.
In the change handler, calculate 8 - $(this).val()
to give the scaling you actually want.
HTML
<input type="range" min="0" max='21' value="7" step="1" id="myRange">
Javascript
$('#myRange').change(function () {
var scaledValue = 8 - $(this).val();
console.log(scaledValue);
});
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With