HI this seems like a simple one yet ill be damned if i can figure it out!
Basically i want to be able to click any combination of the checkboxes and have only the relevant results (Exercises) show in the drop down for me to choose from.
This is exactly what is happening on this website https://www.bodybuilding.com/exercises/finder apart from they are returning a repeater i want to return options to a drop down.
I have it working for just one check box. can someone help me with this request please.
import wixData from 'wix-data'; function trainingFilter (parameter) { if ($w('#chestCheckbox').checked) $w('#trainingDataset').setFilter(wixData.filter() .contains("muscleGroup", $w("#chestCheckbox").value)); else $w('#trainingDataset').setFilter(wixData.filter()) } export function chestCheckbox_change(event) { trainingFilter() }
![](https://static.wixstatic.com/media/a27d24_45d3a5c8bb384bd69a9bb2fc935d7ccc~mv2.png/v1/fill/w_980,h_613,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/a27d24_45d3a5c8bb384bd69a9bb2fc935d7ccc~mv2.png)
![](https://static.wixstatic.com/media/a27d24_5f679a34e88f47108db405ecfb5fdcf0~mv2.png/v1/fill/w_980,h_613,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/a27d24_5f679a34e88f47108db405ecfb5fdcf0~mv2.png)
does anyone know how to sort checkboxes from a database by ascending. I can't seem to put the code in the correct place.
import wixData from 'wix-data'; $w.onReady(function () { $w.onReady(() => { wixData.query('linkCategories2') .find() .then(res => { let options = []; options.push(...res.items.map(category => { return { 'value': category.categoryName, 'label': category.categoryName }; })); $w('#checkboxGroup1').options = options; } }); });
Hi i have begin with coding and have seen your website. i have make a similar website but i cannot code the reset button can you help me with that.
thank you
bump @anthonyb can we re look at this please ? i really need to have this so that the drop down filters even if just one item in 1 checkbox group is ticked.
Example i tick push and i click drop down and i see all push exercises then i choose to click pull and i see all push pull exercises but no leg exercises and so on for all other check boxes, is that something you could help me with ive been trying and trying but im not good enough.
appreicated
Hi Fraser,
It looks like you added individual checkboxes and then grouped them. I know it's going to take some time, but Wix now has checkbox groups and it would be way, way easier to code what you have in mind using checkbox groups.
On a collection that I have that includes a field called "city", I set up a checkbox group of cities and used the code below to filter a dataset displayed in a table:
export function FilterByCity(){ let oCities = []; // Get the indexes of all the checkboxes checked in that group let selectedCities = $w("#checkboxGroup1").selectedIndices; // Now, loop through the checked items and add each city to the Cities array if (selectedCities.length > 0){ for (var i = 0; i < selectedCities.length; i++) { oCities.push($w('#checkboxGroup1').options[selectedCities[i]].value); } $w("#dataset1").setFilter(wixData.filter() .hasSome("city", oCities) ); } else { $w("#dataset1").setFilter(wixData.filter() ); } } export function checkboxGroup1_change(event) { FilterByCity(); }
Since you have four different groups, you would need to add four different hasSome conditions.