Good morning! Hoping there’s a simple solution to my problem :).
I easily created a filter with a set of check boxes, but when I tried to create a second filter to work together with the first, I realized I’m missing something. Might anyone be able to help me figure out what I can’t?
The site page is here: https://londonmiddlebury.wixsite.com/pqchcv1/programs-and-services
The yellow filter works, the green does not
Thank you thank you thank you!
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from 'wix-data';
function AudienceFilter() {
const checkedaudience = [
$w('#checkbox1').checked && 'Adult',
$w('#checkbox2').checked && 'Parent',
$w('#checkbox3').checked && 'Senior',
$w('#checkbox4').checked && 'Newcomer',
$w('#checkbox5').checked && 'Young Adult',
$w('#checkbox6').checked && 'Child',
].filter(Boolean)
const query = checkedaudience.reduce(
(query, audience, i) =>
i === 0
? query.eq('audience', audience)
: query.or(wixData.query('programsANDservices').eq('audience', audience)),
wixData.query('programsANDservices')
)
query.find().then(results => {
//console.log(results.items);
let programsANDservices = results.items
$w('#serviceRepeater').data = programsANDservices
})
}
$w.onReady(function () {
AudienceFilter();
});
export function checkbox1_change(event, $w) {
//Add your code for this event here:
AudienceFilter();
}
export function checkbox2_change(event, $w) {
//Add your code for this event here:
AudienceFilter();
}
export function checkbox3_change(event, $w) {
//Add your code for this event here:
AudienceFilter();
}
export function checkbox4_change(event, $w) {
//Add your code for this event here:
AudienceFilter();
}
export function checkbox5_change(event) {
//Add your code for this event here:
AudienceFilter();
}
export function checkbox6_change(event) {
//Add your code for this event here:
AudienceFilter();
}
function ServiceFilter() {
const checkedservice = [
$w('#checkbox7').checked && 'Health',
$w('#checkbox8').checked && 'Housing',
$w('#checkbox9').checked && 'Education',
$w('#checkbox10').checked && 'Mental Health',
$w('#checkbox11').checked && 'Parenting',
$w('#checkbox12').checked && 'Child Care',
$w('#checkbox13').checked && 'Child Development',
$w('#checkbox14').checked && 'Food',
$w('#checkbox15').checked && 'Employment',
$w('#checkbox16').checked && 'Neighbourhoods',
$w('#checkbox17').checked && 'Volunteering',
$w('#checkbox18').checked && 'Community Health',
].filter(Boolean)
const query = checkedservice.reduce(
(query, serviceCategory, i) =>
i === 0
? query.eq('servicecategory', serviceCategory)
: query.or(wixData.query('programsANDservices').eq('servicecategory', serviceCategory)),
wixData.query('programsANDservices')
)
query.find().then(results => {
//console.log(results.items);
let programsANDservices = results.items
$w('#serviceRepeater').data = programsANDservices
})
}
$w.onReady(function () {
ServiceFilter();
});
export function checkbox7_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox8_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox9_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox10_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox11_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox12_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox13_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox14_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox15_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox16_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox17_change(event) {
//Add your code for this event here:
ServiceFilter();
}
export function checkbox18_change(event) {
//Add your code for this event here:
ServiceFilter();
}