Calculator Tools Calculator Tools
Create

SimplySoundAdvice.com: What is your Body Mass Index (BMI)?

Sep 15, 2023

About this app

Calculate your Body Mass Index (BMI) using our simple tool.

SimplySoundAdvice.com: What is your Body Mass Index (BMI)? SimplySoundAdvice.com: What is your Body Mass Index (BMI)? Unit of Measurement METRIC (Height in cm and Weight in kg) IMPERIAL (Height in feet/inches and Weight in lbs) Height (cm) Weight (kg) Height (ft) Height (in) Weight (lbs) Calculate BMI 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.

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="Calculate your Body Mass Index (BMI) using our simple tool.">
<meta name="keywords" content="BMI, Body Mass Index, Health, Weight, Height">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.2/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/css2?family=Open+Sans:wght@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.
document.addEventListener("DOMContentLoaded", function() {
// Initialize user interface elements
const unitSelect = document.getElementById("unit-select");
const metricInputs = document.getElementById("metric-inputs");
const imperialInputs = document.getElementById("imperial-inputs");
const heightCMInput = document.getElementById("height-cm-input");
const weightKGInput = document.getElementById("weight-kg-input");
const heightFTInput = document.getElementById("height-ft-input");
const heightINInput = document.getElementById("height-in-input");
const weightLBSInput = document.getElementById("weight-lbs-input");
const calculateBtn = document.getElementById("calculate-btn");
const resultContainer = document.getElementById("result-container");
const resultText = document.getElementById("result-text");
const legendContainer = document.getElementById("legend-container");
const interpretationText = document.getElementById("interpretation-text");

// Set initial state
metricInputs.style.display = "none";
imperialInputs.style.display = "none";
resultContainer.style.display = "none";
legendContainer.style.display = "none";

// Event listeners
unitSelect.addEventListener("change", function() {
if (unitSelect.value === "metric") {
metricInputs.style.display = "block";
imperialInputs.style.display = "none";
} else if (unitSelect.value === "imperial") {
metricInputs.style.display = "none";
imperialInputs.style.display = "block";
}
});

calculateBtn.addEventListener("click", function() {
let height, weight;

if (unitSelect.value === "metric") {
height = parseFloat(heightCMInput.value);
weight = parseFloat(weightKGInput.value);
} else if (unitSelect.value === "imperial") {
const heightFT = parseInt(heightFTInput.value);
const heightIN = parseInt(heightINInput.value);
height = (heightFT * 12) + heightIN;
weight = parseFloat(weightLBSInput.value);
}

if (isNaN(height) || isNaN(weight)) {
alert("Please enter valid height and weight values.");
return;
}

let bmi;
if (unitSelect.value === "metric") {
bmi = weight / ((height / 100) ** 2);
} else if (unitSelect.value === "imperial") {
bmi = (weight / (height ** 2)) * 703;
}

resultText.textContent = "Your BMI is " + bmi.toFixed(1);

resultContainer.style.display = "block";
legendContainer.style.display = "block";

if (bmi < 18.5) {
resultText.style.color = "#007bff";
interpretationText.textContent = "Underweight";
interpretationText.style.color = "#007bff";
} else if (bmi >= 18.5 && bmi <= 24.9) {
resultText.style.color = "#28a745";
interpretationText.textContent = "Normal Weight";
interpretationText.style.color = "#28a745";
} else if (bmi >= 25 && bmi <= 29.9) {
resultText.style.color = "#ffc107";
interpretationText.textContent = "Overweight";
interpretationText.style.color = "#ffc107";
} else {
resultText.style.color = "#dc3545";
interpretationText.textContent = "Obese";
interpretationText.style.color = "#dc3545";
}
});
});

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

<style>
body {
font-family: 'Open Sans', sans-serif;
background-color: #f8f9fa;
}

.container {
max-width: 600px;
margin-top: 50px;
}

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

.inputs-container {
margin-bottom: 20px;
}

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

.result-text {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}

.legend-container {
margin-top: 20px;
}

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

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

.interpretation-text {
font-size: 18px;
font-weight: bold;
}
</style>
</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-select">Unit of Measurement</label>
<select id="unit-select" class="form-select">
<option value="metric">METRIC (Height in cm and Weight in kg)</option>
<option value="imperial">IMPERIAL (Height in feet/inches and Weight in lbs)</option>
</select>
</div>

<div id="metric-inputs" class="inputs-container">
<div class="form-group">
<label for="height-cm-input">Height (cm)</label>
<input type="number" id="height-cm-input" class="form-control">
</div>
<div class="form-group">
<label for="weight-kg-input">Weight (kg)</label>
<input type="number" id="weight-kg-input" class="form-control">
</div>
</div>

<div id="imperial-inputs" class="inputs-container">
<div class="form-group">
<label for="height-ft-input">Height (ft)</label>
<input type="number" id="height-ft-input" class="form-control">
</div>
<div class="form-group">
<label for="height-in-input">Height (in)</label>
<input type="number" id="height-in-input" class="form-control">
</div>
<div class="form-group">
<label for="weight-lbs-input">Weight (lbs)</label>
<input type="number" id="weight-lbs-input" class="form-control">
</div>
</div>

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

<div id="result-container" class="result-container">
<p id="result-text" class="result-text"></p>
</div>

<div id="legend-container" class="legend-container">
<div class="legend-item">
<div class="legend-circle" style="background-color: #007bff;"></div>
<div class="legend-text">Underweight: Less than 18.5 BMI</div>
</div>
<div class="legend-item">
<div class="legend-circle" style="background-color: #28a745;"></div>
<div class="legend-text">Normal Weight: 18.5 to 24.9 BMI</div>
</div>
<div class="legend-item">
<div class="legend-circle" style="background-color: #ffc107;"></div>
<div class="legend-text">Overweight: 25 to 29.9 BMI</div>
</div>
<div class="legend-item">
<div class="legend-circle" style="background-color: #dc3545;"></div>
<div class="legend-text">Obese: 30 or more BMI</div>
</div>
</div>

<p id="interpretation-text" class="interpretation-text"></p>

<p class="note-text">Note: BMI is a useful measure for adults. It may not be accurate for athletes, elderly, or children.</p>
</div>
</body>
</html>