-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (47 loc) · 1.63 KB
/
Copy pathscript.js
File metadata and controls
58 lines (47 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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();