Here's a basic implementation of an ERS GLI 2012 calculator using HTML and JavaScript. This calculator uses the formula for Endurance Running Speed (ERS) and the GLI (Gardner-Lockhart Index) score with gender-specific adjustments.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ERS GLI 2012 Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 2rem auto;
padding: 20px;
}
.container {
background: #f9f9f9;
padding: 20px;
border-radius: 8px;
}
input, button {
margin: 0.5rem 0;
padding: 8px;
width: 100%;
}
#result {
margin-top: 20px;
padding: 15px;
background: #e2f5e8;
color: #2c7a4e;
border-radius: 5px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h2>ERS GLI 2012 Calculator</h2>
<form id="calcForm">
<label for="age">Age:</label>
<input type="number" id="age" placeholder="Enter your age" required>
<label>Gender:</label>
<input type="radio" id="male" name="gender" value="male" required>
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label>
<label for="distance">Distance (km):</label>
<input type="number" id="distance" placeholder="Distance in kilometers" step="0.01" required>
<label>Time:</label>
<div class="time-input">
<input type="number" id="minutes" placeholder="Minutes" required>
<input type="number" id="seconds" placeholder="Seconds" required>
</div>
<button type="button" onclick="calculateGLI()">Calculate</button>
</form>
<div id="result"></div>
</div>
<script>
function calculateGLI() {
const age = parseFloat(document.getElementById('age').value);
const gender = document.querySelector('input[name="gender"]:checked').value;
const distance = parseFloat(document.getElementById('distance').value);
const minutes = parseFloat(document.getElementById('minutes').value);
const seconds = parseFloat(document.getElementById('seconds').value);
// Validation checks
if (isNaN(age) || age <= 0) {
alert("Please enter a valid age.");
return;
}
if (!gender) {
alert("Please select your gender.");
return;
}
if (isNaN(distance) || distance <= 0) {
alert("Please enter a valid distance.");
return;
}
if (isNaN(minutes) || isNaN(seconds) || minutes < 0 || seconds < 0) {
alert("Please enter valid time values.");
return;
}
if ((minutes * 60 + seconds) <= 0) {
alert("Time must be greater than 0 seconds.");
return;
}
// Calculate total time in seconds
const timeSeconds = minutes * 60 + seconds;
// Convert distance to meters
const distanceMeters = distance * 1000;
// Calculate Endurance Running Speed (ERS) in m/s
const ERS = distanceMeters / timeSeconds;
// Determine GLI exponent based on gender
const exponent = gender === 'male' ? 0.12 : 0.11;
// Calculate GLI score
const GLI = (3.5 * ERS) / Math.pow(age, exponent);
// Display results
document.getElementById('result').innerHTML =
`<p>Endurance Running Speed (ERS): ${ERS.toFixed(2)} m/s</p>` +
`<p>GLI 2012 Score: ${GLI.toFixed(2)}</p>`;
}
</script>
</body>
</html>
Key Features:
Inputs:
Age
Gender (Male/Female)
Distance in kilometers
Time in minutes and seconds
Calculations:
ERS (Endurance Running Speed): Distance (meters) / Time (seconds)
GLI Score: Uses formula with gender-specific exponent adjustment:
Male: GLI = (3.5 × ERS) / (age^0.12)
Female: GLI = (3.5 × ERS) / (age^0.11)
Validation:
Checks for valid numerical inputs
Ensures time is greater than 0 seconds
Requires gender selection
Output:
Displays both ERS and GLI score with 2 decimal places
Results are shown in a styled result section
Notes:
The formula assumes the GLI 2012 uses the exponent values 0.12 for males and 0.11 for females. Verify the exact formula coefficients if needed.
The calculator converts distance to meters and time to seconds for accurate calculations.
Responsive design with basic styling for better user experience.