What is your Body Mass Index (BMI)?
Sep 15, 2023
v.0
Calculate your Body Mass Index (BMI) and find out if you are underweight, normal weight, overweight, or obese. Body mass index Weight Bmi calculator Height Underweight Normal weight Overweight Obese

Versions  

Bugs  
None!

Get This App On Your Website

1. Copy the code above with the iframe and link.
2. Paste the code into your website.
3. Resize the iframe to fit your website.

Javascript, HTML, CSS Code

                <html>
<head>
<script type="text/javascript"> window.addEventListener('error', function(event) { var message = JSON.parse(JSON.stringify(event.message)); var source = event.filename; var lineno = event.lineno; var colno = event.colno; var error = event.error; window.parent.postMessage({ type: 'iframeError', details: { message: message, source: source, lineno: lineno, colno: colno, error: error ? error.stack : '' } }, '*'); }); window.addEventListener('unhandledrejection', function(event) { window.parent.postMessage({ type: 'iframePromiseRejection', details: { reason: event.reason } }, '*'); }); </script>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>What is your Body Mass Index (BMI)?</title>
<meta name="description" content="Calculate your Body Mass Index (BMI) and find out if you are underweight, normal weight, overweight, or obese.">
<meta name="keywords" content="BMI calculator, body mass index, weight, height, underweight, normal weight, overweight, obese">

<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">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet">

<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.

// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
// Initialize user interface elements
const unitSelector = document.getElementById('unitSelector');
const metricContainer = document.getElementById('metricContainer');
const imperialContainer = document.getElementById('imperialContainer');
const heightCmInput = document.getElementById('heightCmInput');
const weightKgInput = document.getElementById('weightKgInput');
const heightFtInput = document.getElementById('heightFtInput');
const heightInInput = document.getElementById('heightInInput');
const weightLbsInput = document.getElementById('weightLbsInput');
const calculateBtn = document.getElementById('calculateBtn');
const resultContainer = document.getElementById('resultContainer');
const bmiValue = document.getElementById('bmiValue');
const bmiCategory = document.getElementById('bmiCategory');
const legendContainer = document.getElementById('legendContainer');
const noteContainer = document.getElementById('noteContainer');
const restartBtn = document.getElementById('restartBtn');

// Add event listeners
unitSelector.addEventListener('change', handleUnitChange);
calculateBtn.addEventListener('click', calculateBMI);
restartBtn.addEventListener('click', restartCalculator);

// Function to handle unit change
function handleUnitChange() {
const selectedUnit = unitSelector.value;

if (selectedUnit === 'metric') {
metricContainer.style.display = 'block';
imperialContainer.style.display = 'none';
} else {
metricContainer.style.display = 'none';
imperialContainer.style.display = 'block';
}

resultContainer.style.display = 'none';
noteContainer.style.display = 'none';
restartBtn.style.display = 'none';
}

// Function to calculate BMI
function calculateBMI() {
const selectedUnit = unitSelector.value;

if (selectedUnit === 'metric') {
const heightCm = Number(heightCmInput.value);
const weightKg = Number(weightKgInput.value);

if (isNaN(heightCm) || isNaN(weightKg) || heightCm <= 0 || weightKg <= 0) {
alert('Please enter valid height and weight values.');
return;
}

const heightM = heightCm / 100;
const bmi = weightKg / (heightM * heightM);

displayResult(bmi);
} else {
const heightFt = Number(heightFtInput.value);
const heightIn = Number(heightInInput.value);
const weightLbs = Number(weightLbsInput.value);

if (isNaN(heightFt) || isNaN(heightIn) || isNaN(weightLbs) || heightFt < 0 || heightIn < 0 || weightLbs <= 0) {
alert('Please enter valid height and weight values.');
return;
}

const heightInches = heightFt * 12 + heightIn;
const bmi = (weightLbs / (heightInches * heightInches)) * 703;

displayResult(bmi);
}
}

// Function to display BMI result
function displayResult(bmi) {
resultContainer.style.display = 'block';
bmiValue.textContent = bmi.toFixed(1);

if (bmi < 18.5) {
bmiCategory.textContent = 'Underweight';
bmiCategory.style.color = 'blue';
} else if (bmi >= 18.5 && bmi <= 24.9) {
bmiCategory.textContent = 'Normal Weight';
bmiCategory.style.color = 'green';
} else if (bmi >= 25 && bmi <= 29.9) {
bmiCategory.textContent = 'Overweight';
bmiCategory.style.color = 'orange';
} else {
bmiCategory.textContent = 'Obese';
bmiCategory.style.color = 'red';
}

legendContainer.style.display = 'block';
noteContainer.style.display = 'block';
restartBtn.style.display = 'block';
}

// Function to restart calculator
function restartCalculator() {
unitSelector.value = 'metric';
handleUnitChange();
}
});

} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>

<style>
/* App CSS Goes Here */
body {
font-family: 'Roboto', Arial, sans-serif;
}

.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
}

h1 {
text-align: center;
margin-bottom: 20px;
color: #333;
}

.form-group {
margin-bottom: 20px;
}

.form-group label {
display: block;
font-weight: 700;
margin-bottom: 5px;
color: #333;
}

.form-group input {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}

.btn {
display: block;
width: 100%;
padding: 10px;
border: none;
border-radius: 5px;
background-color: #333;
color: #fff;
font-size: 16px;
text-align: center;
cursor: pointer;
transition: background-color 0.3s ease;
}

.btn:hover {
background-color: #555;
}

.result-container {
margin-top: 20px;
display: none;
}

.result-container h2 {
text-align: center;
margin-bottom: 10px;
color: #333;
}

.result-container p {
text-align: center;
margin-bottom: 10px;
font-size: 24px;
}

.legend-container {
margin-top: 20px;
display: none;
text-align: center;
}

.legend-item {
display: inline-block;
margin-right: 10px;
}

.legend-circle {
display: inline-block;
width: 16px;
height: 16px;
border-radius: 50%;
margin-right: 5px;
}

.legend-text {
display: inline-block;
font-weight: 700;
}

.note-container {
margin-top: 20px;
display: none;
text-align: center;
color: #999;
}

.restart-btn {
margin-top: 20px;
display: none;
text-align: center;
}
</style>

<link rel="canonical" href="https://calculator.tools/app/what-is-your-body-mass-index-bmi-119/">
<meta charset="utf-8">

</head>
<body>
<div id="main-container" class="container">
<h1>What is your Body Mass Index (BMI)?</h1>

<div class="form-group">
<label for="unitSelector">Unit of Measurement</label>
<select id="unitSelector">
<option value="metric">METRIC</option>
<option value="imperial">IMPERIAL</option>
</select>
</div>

<div id="metricContainer">
<div class="form-group">
<label for="heightCmInput">Height (cm)</label>
<input type="number" id="heightCmInput" placeholder="Enter height in cm">
</div>
<div class="form-group">
<label for="weightKgInput">Weight (kg)</label>
<input type="number" id="weightKgInput" placeholder="Enter weight in kg">
</div>
</div>

<div id="imperialContainer" style="display: none;">
<div class="form-group">
<label for="heightFtInput">Height (ft)</label>
<input type="number" id="heightFtInput" placeholder="Enter height in ft">
</div>
<div class="form-group">
<label for="heightInInput">Height (in)</label>
<input type="number" id="heightInInput" placeholder="Enter height in in">
</div>
<div class="form-group">
<label for="weightLbsInput">Weight (lbs)</label>
<input type="number" id="weightLbsInput" placeholder="Enter weight in lbs">
</div>
</div>

<button id="calculateBtn" class="btn">Calculate BMI</button>

<div id="resultContainer" class="result-container">
<h2>Your BMI:</h2>
<p id="bmiValue"></p>
<p id="bmiCategory"></p>
</div>

<div id="legendContainer" class="legend-container">
<div class="legend-item">
<span class="legend-circle" style="background-color: blue;"></span>
<span class="legend-text">Underweight</span>
</div>
<div class="legend-item">
<span class="legend-circle" style="background-color: green;"></span>
<span class="legend-text">Normal Weight</span>
</div>
<div class="legend-item">
<span class="legend-circle" style="background-color: orange;"></span>
<span class="legend-text">Overweight</span>
</div>
<div class="legend-item">
<span class="legend-circle" style="background-color: red;"></span>
<span class="legend-text">Obese</span>
</div>
</div>

<div id="noteContainer" class="note-container">
<p>BMI is a useful measure for adults. It may not be accurate for athletes, elderly, or children.</p>
</div>

<div id="restartBtn" class="restart-btn">
<button class="btn">Calculate Again</button>
</div>
</div>
<script type="text/javascript"> var localStoragePrefix = "ct-119"; var lastSave = 0; function saveLocal(data) { if (Date.now() - lastSave < 1000) { return; } let cookie = localStoragePrefix + "=" + JSON.stringify(data) + "; path=" + window.location.pathname + "'; SameSite=Strict"; cookie += "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 1000).toUTCString(); document.cookie = cookie; lastSave = Date.now(); } function loadLocal() { var cookiePrefix = localStoragePrefix + "="; var cookieStart = document.cookie.indexOf(cookiePrefix); if (cookieStart > -1) { let cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) { cookieEnd = document.cookie.length; } var cookieData = document.cookie.substring(cookieStart + cookiePrefix.length, cookieEnd); return JSON.parse(cookieData); } } </script>
<script type="text/javascript"> window.addEventListener('load', function() { var observer = new MutationObserver(function() { window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); observer.observe(document.body, {attributes: true, childList: true, subtree: true}); window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); </script>
</body>
</html>

NEW APPS

These are apps made by the community!

FAQ

What is Calculator Tools?

Calculator Tools allows you to instantly create and generate any simple one page web app for free and immediately have it online to use and share. This means anything! Mini apps, calculators, trackers, tools, games, puzzles, screensavers... anything you can think of that the AI can handle.

The AI uses Javacript, HTML, and CSS programming to code your app up in moments. This currently uses GPT-4 the latest and most powerful version of the OpenAI GPT language model.

What Do You Mean Make An App?

Have you ever just wanted a simple app but didn't want to learn programming or pay someone to make it for you? Calculator Tools is the solution! Just type in your prompt and the AI will generate a simple app for you in seconds. You can then customize it to your liking and share it with your friends.

AI has become so powerful it is that simple these days.

Does This Use ChatGPT?

It uses GPT-4 which is the most powerful model for ChatGPT.

Calculator Tools does not remember things from prompt to prompt, each image is a unique image that does not reference any of the images or prompts previously supplied.