How do I calculate warm-up sets automatically based on working weight?

I’m having trouble with
Building a warm-up set calculator that automatically generates
warm-up sets based on a user’s working weight. I want it to
calculate the right percentages and reps for each set, I have
a working reference at this warm-up set calculator
but struggling to replicate the logic inside Wix.

Working in
Wix Studio Editor / Velo

What I’m trying to do
Take a single input (working weight in kg or lbs), run it through
percentage-based logic (e.g. 40%, 60%, 80% of working weight),
and display a clean table of warm-up sets with reps for each.

What I’ve tried so far
Basic JavaScript logic works for the calculation itself,
but I’m struggling with:

  • Unit switching (kg vs lbs) without breaking the output
  • Displaying results in a clean table format inside Wix
  • Rounding to nearest 2.5kg/5lb increment

Extra context
Is this better handled entirely in frontend Velo code, or is
there a Wix-native way to build this kind of dynamic output table?

This is better done entirely in frontend Velo, no backend needed since it is pure math off one input.

For the table, skip trying to build an HTML table and use a Repeater instead, that is the Wix native way to show a dynamic list of rows:

  1. Add a Repeater with text elements inside for Set, Percent, Weight, Reps.
    1. Feed it an array built from your working weight.
      1. Use onItemReady to fill each row.
    2. For units, keep the working weight stored in one canonical unit internally (say kg always), and only convert for display. If you mutate the stored value every time the unit toggle flips, rounding errors creep in after a few switches.
  2. Something like:

function roundToIncrement(value, increment) {

return Math.round(value / increment) * increment;

}

const WARMUP_SCHEME = [

{ percent: 0.4, reps: 8 },

{ percent: 0.6, reps: 5 },

{ percent: 0.8, reps: 3 },

{ percent: 0.9, reps: 1 }

];

function calculateWarmups(workingWeightKg, unit) {

const increment = unit === “kg” ? 2.5 : 5;

const display = unit === “kg” ? workingWeightKg : workingWeightKg * 2.20462;

return WARMUP_SCHEME.map((step, i) => ({

_id: String(i),
    set: `Set ${i + 1}`,
    percent: `${step.percent * 100}%`,
    weight: `${roundToIncrement(display * step.percent, increment)} ${unit}`,
    reps: step.reps
  }));
}

$w("#warmupRepeater").onItemReady(($item, itemData) => {
  $item("#textSet").text = itemData.set;
  $item("#textPercent").text = itemData.percent;
  $item("#textWeight").text = itemData.weight;
  $item("#textReps").text = `${itemData.reps} reps`;
});

Then on your calculate button, just set $w("#warmupRepeater").data = calculateWarmups(weightInKg, selectedUnit). Keeps the math in one place and the display logic separate, so switching units never breaks the numbers.

If this helped, please mark it as Solved.