HI,
Can any one help me finish this code?
I have a data set called $w("#trainingDataset") its a database full of different exercises.
I want to filter the data set using group check boxes. i have it working on the below code with one issue i have to check at least 1 box in each group there are 4 groups that obviously contain multiple check boxes.
pushPullcheckboxgroup
exerciseTypecheckboxgroup
equipmentCheckboxgroup
muscleGroupcheckboxgroup
you can see the check box groups in the photo.
I want it so that it filters each time i click a check box no matter if that's 1 box or multiple boxes.
for example if i click pull it filters the dropdown to show only the pull exercises.
here's the code that works but only if at least 1 box is checked in each group.
//Exercise filter export function FilterByExercise(){ let ppl = []; let exerciseType = []; let equipmentType = []; let muscleGroup = []; // Get the indexes of all the checkboxes checked in that group let selectedppl = $w("#pushPullcheckboxgroup").selectedIndices; let selectedexerciseType = $w("#exerciseTypecheckboxgroup").selectedIndices; let selectedequipmentType = $w("#equipmentCheckboxgroup").selectedIndices; let selectedmuscleGroup = $w("#muscleGroupcheckboxgroup").selectedIndices; // Now, loop through the checked items and add each field to the array if (selectedppl.length > 0){ for (var i = 0; i < selectedppl.length; i++) { ppl.push($w('#pushPullcheckboxgroup').options[selectedppl[i]].value); } } if (selectedexerciseType.length > 0){ for (var i2 = 0; i2 < selectedexerciseType.length; i2++) { exerciseType.push($w('#exerciseTypecheckboxgroup').options[selectedexerciseType[i2]].value); } } if (selectedequipmentType.length > 0){ for (var i3 = 0; i3 < selectedequipmentType.length; i3++) { equipmentType.push($w('#equipmentCheckboxgroup').options[selectedequipmentType[i3]].value); } } if (selectedmuscleGroup.length > 0){ for (var i4 = 0; i4 < selectedmuscleGroup.length; i4++) { muscleGroup.push($w('#muscleGroupcheckboxgroup').options[selectedmuscleGroup[i4]].value); } } $w("#trainingDataset").setFilter(wixData.filter() .hasSome("ppl", ppl) .hasSome("exerciseType", exerciseType) .hasSome("equipmentType", equipmentType) .hasSome("muscleGroup", muscleGroup) ); } export function pushPullcheckboxgroup_change(event) { FilterByExercise(); } export function exerciseTypecheckboxgroup_change(event) { FilterByExercise(); } export function equipmentCheckboxgroup_change(event) { FilterByExercise(); } export function muscleGroupcheckboxgroup_change(event) { FilterByExercise(); }
![](https://static.wixstatic.com/media/a27d24_451acb971d544c2aaa75263b8c9b54c2~mv2.png/v1/fill/w_980,h_613,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/a27d24_451acb971d544c2aaa75263b8c9b54c2~mv2.png)
bump you under the rock again @Yisrael (Wix) lol
Hi @Yisrael (Wix) sorry to disturb you from that rock! lol
Im not sure what you mean by that exactly ? i could switch it and test it if you show me how?
Example of what i need: if i tick push then click the drop down id like to see all push exercises. If i then choose to also tick pull then id like to see all push and pull exercises but no legs exercises.
This pattern continues with all other check box groups example if i tick push, legs and machine id like the drop down to show me all the available exercises that you push use your legs on a machine.
That make sense?
bump
Bump! wheres @Yisreal at lol ................. very frustrating its so close but not quite there