Heart Rate Calculator Zones

Heart Rate Zone Calculator

Understanding your heart rate zones is crucial for optimizing your workouts. Different zones correspond to different intensities and physiological benefits, from fat burning to improving aerobic capacity and building speed.

If you leave this blank, the calculator will estimate it using the common formula (220 – age).
function calculateHeartRateZones() { var ageInput = document.getElementById("age"); var maxHeartRateInput = document.getElementById("maxHeartRate"); var resultDiv = document.getElementById("result"); var age = parseFloat(ageInput.value); var maxHeartRate = parseFloat(maxHeartRateInput.value); if (isNaN(age) || age = 120) { resultDiv.innerHTML = "Please enter a valid age."; return; } if (isNaN(maxHeartRate) || maxHeartRate = 250) { // Estimate max heart rate if input is invalid or empty maxHeartRate = 220 – age; if (maxHeartRate <= 0) { resultDiv.innerHTML = "Could not estimate Max Heart Rate from age. Please enter it manually."; return; } } // Define heart rate zones as percentages of Max Heart Rate var zones = { "Zone 1 (Very Light)": { min: 0.50, max: 0.60 }, "Zone 2 (Light)": { min: 0.60, max: 0.70 }, "Zone 3 (Moderate)": { min: 0.70, max: 0.80 }, "Zone 4 (Hard)": { min: 0.80, max: 0.90 }, "Zone 5 (Maximum)": { min: 0.90, max: 1.00 } }; var outputHTML = "

Your Heart Rate Zones:

"; outputHTML += "Your Estimated Max Heart Rate: " + maxHeartRate.toFixed(0) + " BPM"; for (var zoneName in zones) { var zone = zones[zoneName]; var lowerBound = maxHeartRate * zone.min; var upperBound = maxHeartRate * zone.max; outputHTML += "" + zoneName + ": " + lowerBound.toFixed(0) + " – " + upperBound.toFixed(0) + " BPM"; } resultDiv.innerHTML = outputHTML; } .heart-rate-calculator { font-family: sans-serif; max-width: 500px; margin: 20px auto; padding: 20px; border: 1px solid #ddd; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .heart-rate-calculator h2 { text-align: center; color: #333; margin-bottom: 20px; } .input-section { margin-bottom: 15px; } .input-section label { display: block; margin-bottom: 5px; font-weight: bold; color: #555; } .input-section input[type="number"] { width: calc(100% – 20px); padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; } .input-section small { display: block; margin-top: 5px; font-size: 0.9em; color: #777; } .button-section { text-align: center; margin-top: 20px; } .button-section button { background-color: #4CAF50; color: white; padding: 12px 25px; border: none; border-radius: 5px; cursor: pointer; font-size: 1.1em; transition: background-color 0.3s ease; } .button-section button:hover { background-color: #45a049; } .result-section { margin-top: 30px; padding: 15px; background-color: #f9f9f9; border: 1px solid #eee; border-radius: 5px; } .result-section h3 { margin-top: 0; color: #333; } .result-section p { margin-bottom: 8px; color: #444; } .result-section strong { color: #0056b3; } .error { color: #d9534f; font-weight: bold; }

Leave a Comment