0
votes

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)

1
What have you tried? Can you post some code or a MCVE? You may be able to improve your question and get better answers. See How do I ask a good question?gfullam

1 Answers

1
votes

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());