-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Membership Fee Calculator</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<h1>Calculate Your Membership Fee</h1> | ||
<form id="membershipForm"> | ||
<fieldset> | ||
<legend>Membership Details</legend> | ||
<label for="attendingLeague">Attending League: | ||
<select name="attendingLeague" id="attendingLeague"> | ||
<option value="Sprint">Sprint</option> | ||
<option value="XC">XC</option> | ||
<option value="Both">Both</option> | ||
</select> | ||
</label> | ||
<br> | ||
<label for="sprintFlown"> | ||
<input type="checkbox" name="sprintFlown" id="sprintFlown"> | ||
Flown Sprint before? | ||
</label> | ||
<br> | ||
<label for="xcFlown"> | ||
<input type="checkbox" name="xcFlown" id="xcFlown"> | ||
Flown XC before? | ||
</label> | ||
<br> | ||
<label for="firstSprint"> | ||
<input type="checkbox" name="firstSprint" id="firstSprint"> | ||
Signing up before first Sprint? | ||
</label> | ||
<br> | ||
<label for="firstXc"> | ||
<input type="checkbox" name="firstXc" id="firstXc"> | ||
Signing before first XC? | ||
</label> | ||
</fieldset> | ||
<p id="membershipFee"> | ||
</p> | ||
</form> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
function calculateFee() { | ||
const attendingLeague = document.getElementById("attendingLeague").value; | ||
const sprintFlown = document.getElementById("sprintFlown").checked; | ||
const xcFlown = document.getElementById("xcFlown").checked; | ||
const firstSprint = document.getElementById("firstSprint").checked; | ||
const firstXc = document.getElementById("firstXc").checked; | ||
|
||
const membershipFee = getMembershipFee( | ||
attendingLeague, | ||
sprintFlown, | ||
xcFlown, | ||
firstSprint, | ||
firstXc | ||
); | ||
document.getElementById( | ||
"membershipFee" | ||
).textContent = `Your membership fee is: $${membershipFee}`; | ||
} | ||
|
||
function getMembershipFee(attendingLeague, sprintFlown, xcFlown, firstSprint = true, firstXc = true) { | ||
// First-time Sprint is free | ||
if (attendingLeague === "Sprint" && !sprintFlown) { | ||
return 0; | ||
} | ||
|
||
// First-time XC without Sprint is $25 | ||
if (attendingLeague === "XC" && !xcFlown && !sprintFlown) { | ||
return 25; | ||
} | ||
|
||
// Sprint only or Both leagues with Sprint flown but not XC | ||
if ((attendingLeague === "Sprint" || (attendingLeague === "Both" && sprintFlown && !xcFlown)) && firstSprint) { | ||
return 25; | ||
} | ||
|
||
// XC only or Both leagues with both flown before | ||
if (attendingLeague === "XC" || (attendingLeague === "Both" && sprintFlown && xcFlown)) { | ||
return 50; | ||
} | ||
|
||
// Late Sprint renewal is $40 | ||
if (attendingLeague === "Sprint" && !firstSprint) { | ||
return 40; | ||
} | ||
|
||
// Late XC renewal is $75 | ||
if (attendingLeague === "XC" && !firstXc) { | ||
return 75; | ||
} | ||
|
||
// Default case, if none of the above conditions are met | ||
return 50; | ||
} | ||
|
||
|
||
document.getElementById('membershipForm').addEventListener('change', calculateFee); | ||
|
||
calculateFee(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
body { | ||
font-family: sans-serif; | ||
margin: 40px; | ||
} | ||
|
||
fieldset { | ||
border: 1px solid #ccc; | ||
padding: 15px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
legend { | ||
font-weight: bold; | ||
padding: 5px; | ||
} | ||
|
||
label { | ||
display: block; | ||
margin-bottom: 5px; | ||
} | ||
|
||
#membershipFee { | ||
font-weight: bold; | ||
margin-top: 15px; | ||
} |