-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocations.js
29 lines (25 loc) · 1.07 KB
/
locations.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
function displayLocations(states, onCheckCounty){
const stateList = document.getElementById('listings');
states.forEach(state => {
// Create a state header item
const stateHeader = document.createElement('div');
stateHeader.classList.add('list-group-item', 'fw-bold');
stateHeader.textContent = state.name;
stateList.appendChild(stateHeader);
// Create a list of cities with checkboxes under the state header
state.cities.forEach(city => {
const cityItem = document.createElement('label');
cityItem.classList.add('list-group-item');
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.classList.add('form-check-input', 'me-1');
checkbox.value = city + ',' + state.name;
checkbox.dataset.state = state.name;
checkbox.onclick = onCheckCounty;
cityItem.appendChild(checkbox);
cityItem.appendChild(document.createTextNode(city));
stateList.appendChild(cityItem);
});
});
}
export {displayLocations};