Multiply two datasets to display the solution rounded up to the nearest multiple of 5 (5,10,15,20).

Members on my website can enter their “Weights” into four separate inputs and four separate databases. On a separate dynamic page linked to various “exercises”, I’ve inputted specific percentages (i.e., 0.6) for each exercises. I need to multiply their “Weights” by the percentages I have inputted on this dynamic page, connect the correct “Weight” to the correct exercise and then round each solution up to the nearest multiple of 5. For instance, if a certain member entered 300 for their bench press “Weight” when they logged in, and for this specific exercise I’ve inputted “0.725” for the percentage specific to this exercise, I would like this to display on my dynamic page as “220”, or 217.5 rounded up to 220.

ericbeisel.com/proform/ss1/css1

Hi Eric,

You could use the Javascript ceil function with a common rounding technique programmers use to get a number rounded to the nearest multiple, 5 in this case. Just call the function and assign the return value for each of your text elements.

export function RoundToMultipleOfFive(pctAdj,Weight){
    let AdjWeight = Math.ceil((Weight*pctAdj)/5)*5;
    return AdjWeight.toString();
}
1 Like