function toggleUnits(unitType) {
var wLabel = document.getElementById("weightLabel");
var hLabel = document.getElementById("heightLabel");
var wInput = document.getElementById("weightInput");
var hInput = document.getElementById("heightInput");
if (unitType === 'metric') {
wLabel.innerHTML = "Weight (kg)";
hLabel.innerHTML = "Height (cm)";
wInput.placeholder = "e.g. 70";
hInput.placeholder = "e.g. 175";
} else {
wLabel.innerHTML = "Weight (lbs)";
hLabel.innerHTML = "Height (inches)";
wInput.placeholder = "e.g. 154";
hInput.placeholder = "e.g. 69";
}
}
function calculateBMI() {
var weight = parseFloat(document.getElementById("weightInput").value);
var height = parseFloat(document.getElementById("heightInput").value);
var units = document.querySelector('input[name="unit"]:checked').value;
var resultDiv = document.getElementById("bmiResult");
var scoreDisplay = document.getElementById("scoreDisplay");
var categoryDisplay = document.getElementById("categoryDisplay");
var rangeInfo = document.getElementById("rangeInfo");
if (isNaN(weight) || isNaN(height) || weight <= 0 || height <= 0) {
alert("Please enter valid positive numbers for weight and height.");
return;
}
var bmi = 0;
if (units === "metric") {
// Formula: kg / (m^2)
var heightInMeters = height / 100;
bmi = weight / (heightInMeters * heightInMeters);
} else {
// Formula: 703 * (lbs / in^2)
bmi = (703 * weight) / (height * height);
}
var roundedBmi = bmi.toFixed(1);
var category = "";
var bgColor = "";
var textColor = "#fff";
if (bmi = 18.5 && bmi = 25 && bmi < 30) {
category = "Overweight";
bgColor = "#e67e22";
} else {
category = "Obesity";
bgColor = "#e74c3c";
}
scoreDisplay.innerHTML = roundedBmi;
categoryDisplay.innerHTML = category;
categoryDisplay.style.backgroundColor = bgColor;
categoryDisplay.style.color = textColor;
rangeInfo.innerHTML = "CDC Adult BMI Categories: Underweight = <18.5 | Healthy = 18.5–24.9 | Overweight = 25–29.9 | Obese = 30 or higher";
resultDiv.style.display = "block";
}
What is the CDC BMI Calculation?
Body Mass Index (BMI) is a screening tool used by the Centers for Disease Control and Prevention (CDC) and healthcare professionals to estimate whether a person has a healthy body weight for their height. While BMI does not measure body fat directly, research has shown that it correlates moderately with more direct measures of body fat.
How the BMI Formula Works
The BMI calculation utilizes two primary variables: mass and height. Depending on which measurement system you use, the formulas are:
- Metric System: Weight (kg) / [Height (m)]²
- Imperial System: [Weight (lb) / Height (in)²] x 703
CDC Weight Status Categories
For adults 20 years and older, BMI is interpreted using standard weight status categories. These categories are the same for men and women of all body types and ages:
| BMI Range |
Weight Status |
| Below 18.5 |
Underweight |
| 18.5 – 24.9 |
Healthy Weight |
| 25.0 – 29.9 |
Overweight |
| 30.0 and Above |
Obesity |
Calculation Examples
Example 1 (Metric): An individual weighs 75 kilograms and is 180 centimeters tall (1.8 meters).
Calculation: 75 / (1.8 * 1.8) = 75 / 3.24 = 23.1 BMI (Healthy Weight).
Example 2 (Imperial): An individual weighs 160 pounds and is 5 feet 10 inches tall (70 inches).
Calculation: (160 / 4900) * 703 = 0.03265 * 703 = 22.9 BMI (Healthy Weight).
Important Considerations
It is important to remember that BMI is a screening tool, not a diagnostic one. A high BMI can be a sign of high body fat, but it can also be influenced by high muscle mass (common in athletes) or bone density. Factors like age, sex, ethnicity, and muscle mass are not accounted for in the basic BMI calculation. Always consult with a medical professional to discuss your results and overall health status.