I have a table that is connected to a dataset (that is generated from a form submission). I want to be able to filter the Classes Offered field from my database based on the checkboxes that I have selected (could be 1 or multiple checkboxes selected at once to filter the data). But my code seems to only be working with one checkbox selected.
Can someone help me determine the issue or if there is a better way for this to work. I have attached a picture and my code.
Here is a picture of page with table
![](https://static.wixstatic.com/media/a27d24_1e988351da784d80a7f333c77c44ebc7~mv2.jpg/v1/fill/w_980,h_495,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/a27d24_1e988351da784d80a7f333c77c44ebc7~mv2.jpg)
Here is my code
import wixData from 'wix-data';
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
$w.onReady(function () {
$w("#checkbox1").value = ''; //by having ' ' it makes the value equal 'nothing' when the page is loaded
$w("#checkbox2").value = '';
$w("#checkbox3").value = '';
$w("#checkbox4").value = '';
$w("#checkbox5").value = '';
});
export function checkbox1_click() {
Basic();
}
export function checkbox2_click() {
Advance();
}
export function checkbox3_click() {
Junior();
}
export function checkbox4_click() {
Extreme();
}
export function checkbox5_click() {
Toning();
}
//because the page started with all the value to equal 'nothing', now we will set the values to equal the real value
function Basic() { if ($w("#checkbox1").value === '') { $w("#checkbox1").value = 'Basic'; } else { $w("#checkbox1").value = ''; } } function Advance() { if ($w("#checkbox2").value === '') { $w("#checkbox2").value = 'Advance'; } else { $w("#checkbox2").value = ''; } } function Junior() { if ($w("#checkbox3").value === '') { $w("#checkbox3").value = 'Junior'; } else { $w("#checkbox3").value = ''; } } function Extreme() { if ($w("#checkbox4").value === '') { $w("#checkbox4").value = 'Extreme'; } else { $w("#checkbox4").value = ''; } } function Toning() { if ($w("#checkbox5").value === '') { $w("#checkbox5").value = 'Toning'; } else { $w("#checkbox5").value = ''; } } function valueCombine() { let checkedValue = $w("#checkbox1").value + "" + $w("#checkbox2").value + "" + $w("#checkbox3").value + "" + $w("#checkbox4").value+ "" + $w("#checkbox5").value; $w("#input1").value = checkedValue; } export function button1_click(event, $w) { valueCombine(); $w("#dataset1").setFilter(wixData.filter() .contains("classesOffered", $w("#checkbox1").value + "" + $w("#checkbox2").value + "" + $w("#checkbox3").value + "" + $w("#checkbox4").value+ "" + $w("#checkbox5").value) ); }
hey these guys helped me in the past, maybe they can help you too https://www.vorbly.com/Vorbly-Code/WIX-REPEATER-MULTIPLE-CHECKBOX-FILTERS
Hey,
Using arrays and wixData Filter's .hasSome function will help you achieve your goal.
Shan