top of page

Add A Body Composition Calculator


Fitness pair looking at a laptop in a living room
Calculate your body composition widget created by Doriel Alie

In today's digital age, personal trainers and web designers constantly seek innovative ways to engage their audience and provide valuable tools on their websites. One such tool that can add immense value to fitness websites is a Body Composition Calculator. This calculator helps visitors view their fitness progress and keeps them engaged on your website. In this blog, we'll walk you through the process of adding a Body Composition Calculator to your Wix website, allowing users to instantly access their fat percentage, BMI, and BMR readings.


Follow the instructions in the video below, and copy the code into your website.





Code for the Calculate Button:


const gender = $w("#gender").value.toLowerCase(); // Make sure gender is in lowercase for comparison


const weight = parseFloat($w("#weight").value);

const height = parseFloat($w("#height").value);

const age = parseFloat($w("#age").value);


let bmi = (weight / Math.pow(height / 100, 2)).toFixed(1);

let bmr, fatpercentage;


if (gender === "male") {

bmr = Math.round((66.5 + 13.75 * weight + 5.003 * height - 6.775 * age));

fatpercentage = Math.round(1.39 * bmi + 0.16 * age - 10.34 * 1 - 9);

} else if (gender === "female") {

bmr = Math.round(655.1 + 9.563 * weight + 1.850 * height - 4.676 * age);

fatpercentage = Math.round(1.39 * bmi + 0.16 * age - 10.34 * 0 - 9);

}


$w("#bmi").text = `Body Mass Index: ${bmi}`;

$w("#bmr").text = `Basal Metabolic Rate: ${bmr} kcal`;

$w("#fat").text = `Body Fat Percentage: ${fatpercentage.toFixed(1)} %`;

}




I hope you find this tutorial easy to follow. Please follow my YouTube Channel for more freebies, and contact me if you'd like to discuss further developing this feature.


Thanks,


Doriel

bottom of page