-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
81 lines (73 loc) · 4.13 KB
/
script.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//We're using an object for our data structure. There is not limit to the number of clubs and interests we can add
const clubs = [
{ name: "Computer Science Club", interests: ["programming","technology","science"]},
{ name: "Fellowship of Christian Athletes", interests: ["faith","encouragement"]},
{ name: "Debate Team", interests: ["competition","writing","debate"]},
{ name: "DECA", interests: ["business","entrepreneur","finance"]},
{ name: "Model United Nations", interests: ["debate","research"]},
{ name: "Crochet Club", interests: ["creativity"]},
{ name: "Word Worms", interests: ["creativity","writing"]},
{ name: "Student Government", interests: ["leadership"]},
{ name: "We Dine Together", interests: ["kindness"]},
{ name: "Future Doctors of America", interests: ["medical field","science"]},
{ name: "Envirothon", interests: ["competition","science","environment"]},
{ name: "Green Club", interests: ["environment"]},
{ name: "Academic World Quest", interests: ["competition",]},
{ name: "Alliance Club", interests: ["kindness"]},
{ name: "American Sign Language Club", interests: ["languages"]},
{ name: "Animal Welfare", interests: ["environment", "kindness","volunteering"]},
{ name: "Arts & Crafts Club", interests: ["creativity","art"]},
{ name: "Beach Volleyball Club", interests: ["athletics"]},
{ name: "Best Buddies", interests: ["kindness","encouragement"]},
{ name: "Bible Study Club", interests: ["faith"]},
{ name: "Chess Club", interests: ["competition"]},
{ name: "City of Naples Youth Council", interests: ["leadership"]},
{ name: "Culture Club", interests: ["cultures"]},
{ name: "Drawing for Dementia", interests: ["art","kindness","volunteering"]},
{ name: "Engineering & Robotics", interests: ["science","leadership"]},
{ name: "Fencing Club", interests: ["athletics"]},
{ name: "Film Society", interests: ["films","art"]},
{ name: "Finance Club", interests: ["finance","business"]},
{ name: "Future Florida Educators of America", interests: ["leadership","encouragement"]},
{ name: "Interact Club", interests: ["volunteering"]},
{ name: "Journalism Club", interests: ["art", "creativity"]},
{ name: "Key Club", interests: ["leadership","volunteering"]},
{ name: "Kids CAN", interests: ["volunteering","kindness"]},
{ name: "Mu Alpha Theta", interests: ["competition"]},
{ name: "Pickleball Club", interests: ["athletics"]},
{ name: "Ping Pong Club", interests: ["athletics"]},
{ name: "Scholar Bowl", interests: ["competition"]},
{ name: "Spanish Honor Society (La Sociedad Honoraria Hispánica)", interests: ["languages","cultures"]},
{ name: "Spreading Sunshine", interests: ["creativity","writing","volunteering"]},
{ name: "Student Government Association", interests: ["leadership"]},
{ name: "Tabletop Gaming Club", interests: ["gaming","creativity"]},
{ name: "TOMS Campus Club", interests: ["volunteering","kindness"]},
{ name: "JROTC Drum Corps", interests: ["music"]},
// Add more clubs and their associated interests
];
//Below you will find the JavaScript code for our club page's functionality
// Function to filter clubs based on selected interests
function findClubs() {
const selectedInterests = Array.from(document.querySelectorAll('input[name="interest"]:checked'))
.map(el => el.value);
const matchingClubs = clubs.filter(club => {
return club.interests.some(interest => selectedInterests.includes(interest));
});
displayClubs(matchingClubs);
}
// Function to display the matching clubs
function displayClubs(clubs) {
const resultsContainer = document.getElementById("results");
resultsContainer.innerHTML = "";
if (clubs.length === 0) {
resultsContainer.innerHTML = "<p>No matching clubs found.</p>";
} else {
const clubList = document.createElement("ul");
clubs.forEach(club => {
const listItem = document.createElement("li");
listItem.textContent = club.name;
clubList.appendChild(listItem);
});
resultsContainer.appendChild(clubList);
}
}