SimplySoundAdvice.com: What is your Body Mass Index (BMI)?
About this app
A BMI Calculator to determine an individual's body mass index.
SimplySoundAdvice.com: What is your Body Mass Index (BMI)? What is your Body Mass Index (BMI)? Metric (Height in cm, Weight in kg) Imperial (Height in ft/in, Weight in lbs) Calculate Your BMI: Category: Underweight: Less than 18.5 BMI Normal Weight: 18.5 to 24.9 BMI Overweight: 25 to 29.9 BMI Obese: 30 or more BMI Note: BMI is a useful measure for adults. It may not be accurate for athletes, elderly, or children. Restart
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>SimplySoundAdvice.com: What is your Body Mass Index (BMI)?</title>
<meta name="description" content="A BMI Calculator to determine an individual's body mass index.">
<meta name="keywords" content="BMI, Calculator, Body Mass Index, Health">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript">
try {
const bmiCategories = [
{ label: "Underweight", min: 0, max: 18.4, color: "blue" },
{ label: "Normal Weight", min: 18.5, max: 24.9, color: "green" },
{ label: "Overweight", min: 25, max: 29.9, color: "orange" },
{ label: "Obese", min: 30, max: Infinity, color: "red" }
];
// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
document.getElementById('calculate').addEventListener('click', calculateBMI);
document.getElementById('restart').addEventListener('click', restart);
});
function calculateBMI() {
const unit = document.querySelector('input[name="unit"]:checked').value;
let height, weight, bmi;
switch(unit) {
case 'metric':
height = parseFloat(document.getElementById('height-metric').value);
weight = parseFloat(document.getElementById('weight-metric').value);
bmi = weight / Math.pow((height / 100), 2);
break;
case 'imperial':
const heightFt = parseFloat(document.getElementById('height-ft').value);
const heightIn = parseFloat(document.getElementById('height-in').value);
height = heightFt * 12 + heightIn;
weight = parseFloat(document.getElementById('weight-imperial').value);
bmi = (weight / Math.pow(height, 2)) * 703;
break;
}
// Find the correct category for the calculated BMI
const category = bmiCategories.find(c => bmi >= c.min && bmi <= c.max);
document.getElementById('bmi').innerHTML = bmi.toFixed(2);
document.getElementById('bmi').style.color = category.color;
document.getElementById('category').innerHTML = category.label;
document.getElementById('category').style.color = category.color;
}
function restart() {
document.getElementById('height-metric').value = '';
document.getElementById('weight-metric').value = '';
document.getElementById('height-ft').value = '';
document.getElementById('height-in').value = '';
document.getElementById('weight-imperial').value = '';
document.getElementById('bmi').innerHTML = '';
document.getElementById('category').innerHTML = '';
}
} catch (error) {
throw error;
}
</script>
<style>
.circle {
display: inline-block;
width: 15px;
height: 15px;
margin-right: 5px;
border-radius: 50%;
}
.blue { background-color: blue; }
.green { background-color: green; }
.orange { background-color: orange; }
.red { background-color: red; }
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>What is your Body Mass Index (BMI)?</h1>
<div>
<label><input type="radio" name="unit" value="metric" checked> Metric (Height in cm, Weight in kg)</label><br>
<label><input type="radio" name="unit" value="imperial"> Imperial (Height in ft/in, Weight in lbs)</label>
</div>
<div>
<input type="number" id="height-metric" placeholder="Height (cm)" min="140" max="210">
<input type="number" id="weight-metric" placeholder="Weight (kg)" min="40" max="200">
</div>
<div>
<input type="number" id="height-ft" placeholder="Height (ft)" min="4" max="7">
<input type="number" id="height-in" placeholder="Height (in)" min="0" max="11">
<input type="number" id="weight-imperial" placeholder="Weight (lbs)" min="88" max="440">
</div>
<button id="calculate">Calculate</button>
<h2>Your BMI: <span id="bmi"></span></h2>
<h2>Category: <span id="category"></span></h2>
<div id="legend">
<div><span class="circle blue"></span> Underweight: Less than 18.5 BMI</div>
<div><span class="circle green"></span> Normal Weight: 18.5 to 24.9 BMI</div>
<div><span class="circle orange"></span> Overweight: 25 to 29.9 BMI</div>
<div><span class="circle red"></span> Obese: 30 or more BMI</div>
</div>
<p>Note: BMI is a useful measure for adults. It may not be accurate for athletes, elderly, or children.</p>
<button id="restart">Restart</button>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!