Reputation: 1113
I am trying to populate a range input in my application with dynamic min and max values. I am returned a default number from the server and need to determine the min (1/5 of default) and max (5x's default) values to set on the range input. The default value, what the range is currently set to, must be in the middle of the slider.
For example:
min (1/5 of 700) |______________| default (ex. 700) |_______________| max (5x's700)
Upvotes: 0
Views: 337
Reputation: 2815
Are you looking for a function that divides a number by 5, and multiplies it by 5? If so, this should work, JS fiddle here: https://jsfiddle.net/eexp41e6/2/
function getNumber() {
return 5;
}
function determineMinMax() {
number = getNumber();
min = number / 5;
max = number * 5;
strOut = 'Min is: ' + min + '\nDefault is: '+ number +'\nMax is: ' + max;
return(strOut);
}
alert(determineMinMax());
Upvotes: 1