How to Calculate Respiration Rate

Respiration Rate Calculator

Respiration rate, also known as breathing rate, is the number of breaths a person takes per minute. It's a vital sign that indicates how well your body is functioning. A normal resting respiration rate for an adult is typically between 12 and 20 breaths per minute. Factors like age, activity level, illness, and certain medications can affect this rate.

function calculateRespirationRate() { var breathsInput = document.getElementById("breaths"); var timeInput = document.getElementById("timeInSeconds"); var resultDiv = document.getElementById("result"); var breaths = parseFloat(breathsInput.value); var timeInSeconds = parseFloat(timeInput.value); if (isNaN(breaths) || isNaN(timeInSeconds) || timeInSeconds <= 0) { resultDiv.innerHTML = "Please enter valid numbers for breaths and time (time must be greater than 0)."; return; } var breathsPerMinute = (breaths / timeInSeconds) * 60; resultDiv.innerHTML = "

Your Respiration Rate:

" + "" + breathsPerMinute.toFixed(2) + " breaths per minute"; } .calculator-container { font-family: sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 400px; margin: 20px auto; background-color: #f9f9f9; } .calculator-container h2 { text-align: center; color: #333; margin-bottom: 15px; } .calculator-container p { text-align: justify; color: #555; line-height: 1.6; margin-bottom: 20px; } .input-section { display: flex; flex-direction: column; gap: 15px; margin-bottom: 20px; } .input-section label { font-weight: bold; color: #444; } .input-section input[type="number"] { padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 16px; } .calculator-container button { background-color: #4CAF50; color: white; padding: 12px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; width: 100%; transition: background-color 0.3s ease; } .calculator-container button:hover { background-color: #45a049; } #result { margin-top: 20px; padding: 15px; border: 1px solid #eee; border-radius: 4px; background-color: #fff; text-align: center; } #result h3 { margin-top: 0; color: #333; } #result p { font-size: 18px; font-weight: bold; color: #007bff; }

Leave a Comment