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 = "