Attack Rate Calculation Example

Attack Rate Calculator

The attack rate is a fundamental epidemiological measure used to quantify the risk of developing a disease or experiencing a specific outcome within a defined population over a certain period. It is particularly useful in outbreak investigations to understand the proportion of individuals who become ill among those exposed to a risk factor or in a defined population.

function calculateAttackRate() { var populationExposedInput = document.getElementById("populationExposed"); var casesInExposedInput = document.getElementById("casesInExposed"); var resultDiv = document.getElementById("result"); var populationExposed = parseFloat(populationExposedInput.value); var casesInExposed = parseFloat(casesInExposedInput.value); if (isNaN(populationExposed) || isNaN(casesInExposed)) { resultDiv.innerHTML = "Please enter valid numbers for both fields."; return; } if (populationExposed <= 0) { resultDiv.innerHTML = "Total population exposed must be greater than zero."; return; } if (casesInExposed populationExposed) { resultDiv.innerHTML = "Number of cases cannot exceed the total population exposed."; return; } var attackRate = (casesInExposed / populationExposed) * 100; resultDiv.innerHTML = "

Attack Rate Calculation

" + "Total Population Exposed: " + populationExposed.toLocaleString() + "" + "Number of Cases in Exposed Population: " + casesInExposed.toLocaleString() + "" + "Calculated Attack Rate: " + attackRate.toFixed(2) + "%"; } .calculator-container { font-family: sans-serif; border: 1px solid #ddd; padding: 20px; border-radius: 8px; max-width: 500px; margin: 20px auto; background-color: #f9f9f9; } .calculator-container h2 { text-align: center; color: #333; margin-bottom: 20px; } .calculator-container p { color: #555; line-height: 1.6; margin-bottom: 15px; } .inputs { margin-bottom: 20px; display: grid; grid-template-columns: 1fr; gap: 15px; } .input-group { display: flex; flex-direction: column; } .input-group label { margin-bottom: 8px; font-weight: bold; color: #444; } .input-group input { padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; } button { display: block; width: 100%; padding: 12px 20px; background-color: #007bff; color: white; border: none; border-radius: 4px; font-size: 18px; cursor: pointer; transition: background-color 0.3s ease; margin-bottom: 20px; } button:hover { background-color: #0056b3; } .result-container { background-color: #e9ecef; padding: 15px; border-radius: 5px; border: 1px solid #ced4da; text-align: center; } .result-container h3 { color: #28a745; margin-top: 0; } .result-container p { margin-bottom: 5px; color: #333; }

Leave a Comment