function toggleUnits(system) {
var standardDiv = document.getElementById('standardHeightInputs');
var metricDiv = document.getElementById('metricHeightInput');
var weightLabel = document.getElementById('weightLabel');
var weightInput = document.getElementById('bmiWeight');
if (system === 'standard') {
standardDiv.style.display = 'block';
metricDiv.style.display = 'none';
weightLabel.innerText = 'Weight (Pounds):';
weightInput.placeholder = 'e.g. 160';
} else {
standardDiv.style.display = 'none';
metricDiv.style.display = 'block';
weightLabel.innerText = 'Weight (Kilograms):';
weightInput.placeholder = 'e.g. 70';
}
document.getElementById('bmiResult').style.display = 'none';
}
function calculateCDC_BMI() {
var unitSystem = document.querySelector('input[name="unitSystem"]:checked').value;
var weight = parseFloat(document.getElementById('bmiWeight').value);
var bmi = 0;
if (isNaN(weight) || weight <= 0) {
alert("Please enter a valid weight.");
return;
}
if (unitSystem === 'standard') {
var ft = parseFloat(document.getElementById('bmiHeightFt').value) || 0;
var inches = parseFloat(document.getElementById('bmiHeightIn').value) || 0;
var totalInches = (ft * 12) + inches;
if (totalInches <= 0) {
alert("Please enter a valid height.");
return;
}
// Formula: BMI = 703 × weight (lbs) / [height (in)]^2
bmi = (703 * weight) / (totalInches * totalInches);
} else {
var cm = parseFloat(document.getElementById('bmiHeightCm').value);
if (isNaN(cm) || cm <= 0) {
alert("Please enter a valid height.");
return;
}
var meters = cm / 100;
// Formula: BMI = kg / [height (m)]^2
bmi = weight / (meters * meters);
}
displayBMIResults(bmi);
}
function displayBMIResults(bmi) {
var resultDiv = document.getElementById('bmiResult');
var valDisplay = document.getElementById('bmiValueDisplay');
var catDisplay = document.getElementById('bmiCategoryDisplay');
var roundedBMI = bmi.toFixed(1);
var category = "";
var color = "";
if (bmi = 18.5 && bmi = 25 && bmi < 30) {
category = "Overweight";
color = "#d35400";
} else {
category = "Obesity";
color = "#c0392b";
}
valDisplay.innerText = "Your BMI: " + roundedBMI;
catDisplay.innerText = "Category: " + category;
resultDiv.style.backgroundColor = color + "22"; // 22 is for transparency
resultDiv.style.border = "2px solid " + color;
catDisplay.style.color = color;
resultDiv.style.display = 'block';
}
Understanding the CDC BMI Calculator
Body Mass Index (BMI) is a tool used widely by healthcare professionals, including those at the Centers for Disease Control and Prevention (CDC), to screen for weight categories that may lead to health problems. It is a mathematical calculation that relates a person's weight to their height.
Why Use BMI?
While BMI does not measure body fat directly, it is frequently used as a screening tool because it correlates fairly strongly with more direct measures of body fat (such as underwater weighing or skinfold thickness tests). It is an inexpensive and easy-to-perform method of screening for weight categories that may indicate health risks like cardiovascular disease, type 2 diabetes, and certain cancers.
CDC BMI Categories for Adults
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
Example Calculations
Example 1 (Standard Units): An individual who weighs 160 lbs and is 5 feet 9 inches tall.
1. Height in inches: (5 * 12) + 9 = 69 inches.
2. Formula: (160 / (69 * 69)) * 703 = 23.6 BMI (Healthy Weight).
Example 2 (Metric Units): An individual who weighs 85 kg and is 175 cm tall.
1. Height in meters: 175 / 100 = 1.75 m.
2. Formula: 85 / (1.75 * 1.75) = 27.8 BMI (Overweight).
Limitations of BMI
It is important to remember that BMI is a screening tool, not a diagnostic one. It has some limitations:
Muscle Mass: Athletes and people with high muscle mass may have a high BMI but very low body fat.
Age: Older adults tend to have more body fat than younger adults with the same BMI.
Ethnicity: The relationship between BMI and body fat can vary among different ethnic groups.
If your BMI falls outside the "Healthy Weight" range, the CDC recommends consulting with a healthcare provider to perform further assessments, such as measurements of skinfold thickness, diet, physical activity, and family history.