SimplySoundAdvice.com: What is your Body Mass Index (BMI)?
Sep 15, 2023
v.0
Calculate your Body Mass Index (BMI) using this simple tool. Calculator Health Bmi Body mass index Weight Height

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>SimplySoundAdvice.com: What is your Body Mass Index (BMI)?</title>
<meta name="description" content="Calculate your Body Mass Index (BMI) using this simple tool.">
<meta name="keywords" content="BMI, Body Mass Index, Health, Weight, Height, Calculator">

<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" rel="stylesheet">

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

// Constants
const METRIC = 'metric';
const IMPERIAL = 'imperial';

// Variables
let unit;
let height;
let weight;

// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
// Initialize user interface elements
const unitSelection = document.getElementById('unit-selection');
const heightContainer = document.getElementById('height-container');
const weightContainer = document.getElementById('weight-container');
const calculateButton = document.getElementById('calculate-button');
const bmiResult = document.getElementById('bmi-result');
const bmiLegend = document.getElementById('bmi-legend');

// Event listeners
unitSelection.addEventListener('change', handleUnitSelectionChange);
calculateButton.addEventListener('click', calculateBMI);

// Functions
function handleUnitSelectionChange(event) {
unit = event.target.value;

if (unit === METRIC) {
heightContainer.innerHTML = `
<label for="height">Height (cm):</label>
<input type="number" id="height" required>
`;
weightContainer.innerHTML = `
<label for="weight">Weight (kg):</label>
<input type="number" id="weight" required>
`;
} else if (unit === IMPERIAL) {
heightContainer.innerHTML = `
<label for="feet">Height (ft):</label>
<input type="number" id="feet" required>
<label for="inches">Height (in):</label>
<input type="number" id="inches" required>
`;
weightContainer.innerHTML = `
<label for="weight">Weight (lbs):</label>
<input type="number" id="weight" required>
`;
}
}

function calculateBMI() {
// Get user input values
if (unit === METRIC) {
height = parseInt(document.getElementById('height').value);
weight = parseInt(document.getElementById('weight').value);
} else if (unit === IMPERIAL) {
const feet = parseInt(document.getElementById('feet').value);
const inches = parseInt(document.getElementById('inches').value);
height = feet * 12 + inches;
weight = parseInt(document.getElementById('weight').value);
}

// Input validation
let error = false;
let errorMessage = '';

if (unit === METRIC) {
if (height < 140 || height > 210) {
error = true;
errorMessage += 'Height must be between 140 cm and 210 cm. ';
}
if (weight < 40 || weight > 200) {
error = true;
errorMessage += 'Weight must be between 40 kg and 200 kg. ';
}
} else if (unit === IMPERIAL) {
if (height < 55 || height > 83) {
error = true;
errorMessage += 'Height must be between 4\'7" (55 inches) and 6\'11" (83 inches). ';
}
if (weight < 88 || weight > 440) {
error = true;
errorMessage += 'Weight must be between 88 lbs and 440 lbs. ';
}
}

if (error) {
alert(errorMessage);
return;
}

// Calculate BMI
let bmi;
if (unit === METRIC) {
const heightInMeters = height / 100;
bmi = weight / (heightInMeters * heightInMeters);
} else if (unit === IMPERIAL) {
bmi = (weight / (height * height)) * 703;
}

// Display results
bmiResult.innerHTML = `
<h2>Your BMI: ${bmi.toFixed(1)}</h2>
`;

if (bmi < 18.5) {
bmiResult.style.color = 'blue';
bmiLegend.innerHTML = `
<div class="legend-item">
<div class="legend-circle" style="background-color: blue;"></div>
<div class="legend-label">Underweight: Less than 18.5 BMI</div>
</div>
`;
} else if (bmi >= 18.5 && bmi < 25) {
bmiResult.style.color = 'green';
bmiLegend.innerHTML = `
<div class="legend-item">
<div class="legend-circle" style="background-color: green;"></div>
<div class="legend-label">Normal Weight: 18.5 to 24.9 BMI</div>
</div>
`;
} else if (bmi >= 25 && bmi < 30) {
bmiResult.style.color = 'orange';
bmiLegend.innerHTML = `
<div class="legend-item">
<div class="legend-circle" style="background-color: orange;"></div>
<div class="legend-label">Overweight: 25 to 29.9 BMI</div>
</div>
`;
} else {
bmiResult.style.color = 'red';
bmiLegend.innerHTML = `
<div class="legend-item">
<div class="legend-circle" style="background-color: red;"></div>
<div class="legend-label">Obese: 30 or more BMI</div>
</div>
`;
}
}
});

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

<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #f6f6f6;
}

h1 {
text-align: center;
margin-top: 20px;
margin-bottom: 30px;
color: #333;
font-size: 24px;
}

.container {
max-width: 500px;
margin: 0 auto;
}

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

label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}

input[type="number"] {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}

.btn-primary {
display: block;
width: 100%;
padding: 10px;
font-size: 16px;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}

.btn-primary:hover {
background-color: #0056b3;
}

#bmi-result {
text-align: center;
margin-bottom: 20px;
}

.legend-item {
display: flex;
align-items: center;
margin-bottom: 10px;
}

.legend-circle {
width: 20px;
height: 20px;
border-radius: 50%;
margin-right: 10px;
}

.legend-label {
color: #555;
}
</style>

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

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

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

<div id="height-container" class="form-group">
<label for="height">Height (cm):</label>
<input type="number" id="height" required>
</div>

<div id="weight-container" class="form-group">
<label for="weight">Weight (kg):</label>
<input type="number" id="weight" required>
</div>

<button id="calculate-button" class="btn-primary">Calculate BMI</button>

<div id="bmi-result"></div>

<div id="bmi-legend">
<div class="legend-item">
<div class="legend-circle" style="background-color: blue;"></div>
<div class="legend-label">Underweight: Less than 18.5 BMI</div>
</div>
<div class="legend-item">
<div class="legend-circle" style="background-color: green;"></div>
<div class="legend-label">Normal Weight: 18.5 to 24.9 BMI</div>
</div>
<div class="legend-item">
<div class="legend-circle" style="background-color: orange;"></div>
<div class="legend-label">Overweight: 25 to 29.9 BMI</div>
</div>
<div class="legend-item">
<div class="legend-circle" style="background-color: red;"></div>
<div class="legend-label">Obese: 30 or more BMI</div>
</div>
</div>

<p class="note">Note: BMI is a useful measure for adults. It may not be accurate for athletes, elderly, or children.</p>
</div>
<script type="text/javascript"> var localStoragePrefix = "ct-120"; 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.