Resting Metabolic Rate (RMR) Calculator
Your Resting Metabolic Rate (RMR) is the number of calories your body burns at rest to maintain basic life-sustaining functions like breathing, circulation, and cell production. It's a crucial component of your total daily energy expenditure. Knowing your RMR can help you understand your calorie needs for weight management and overall health.
function calculateRMR() {
var gender = document.getElementById("gender").value;
var age = document.getElementById("age").value;
var weight = document.getElementById("weight").value;
var height = document.getElementById("height").value;
var rmr = 0;
if (age === "" || weight === "" || height === "") {
document.getElementById("result").innerHTML = "Please fill in all fields.";
return;
}
var ageNum = parseFloat(age);
var weightNum = parseFloat(weight);
var heightNum = parseFloat(height);
if (isNaN(ageNum) || isNaN(weightNum) || isNaN(heightNum) || ageNum <= 0 || weightNum <= 0 || heightNum <= 0) {
document.getElementById("result").innerHTML = "Please enter valid positive numbers for age, weight, and height.";
return;
}
if (gender === "male") {
// Mifflin-St Jeor Equation for Men
rmr = (10 * weightNum) + (6.25 * heightNum) – (5 * ageNum) + 5;
} else if (gender === "female") {
// Mifflin-St Jeor Equation for Women
rmr = (10 * weightNum) + (6.25 * heightNum) – (5 * ageNum) – 161;
}
document.getElementById("result").innerHTML = "
Your Resting Metabolic Rate (RMR) is:
" + rmr.toFixed(2) + " calories per day";
}
.calculator-wrapper {
font-family: sans-serif;
max-width: 600px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.calculator-wrapper h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.calculator-wrapper p {
line-height: 1.6;
color: #555;
margin-bottom: 20px;
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-group input[type="number"],
.input-group select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
}
.input-group button {
padding: 12px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1.1em;
transition: background-color 0.3s ease;
grid-column: 1 / -1; /* Span across all columns */
margin-top: 10px;
}
.input-group button:hover {
background-color: #45a049;
}
#result {
margin-top: 25px;
padding: 15px;
background-color: #f9f9f9;
border: 1px solid #eee;
border-radius: 4px;
text-align: center;
}
#result h3 {
margin-bottom: 10px;
color: #333;
}