Hello I want to filter my data based on checkboxes checked.
I have 3 checkboxes.
<input type="checkbox" name="shoes" value="shoes" class="storesCheckBox" />
<input type="checkbox" name="clothes" value="clothes" class="storesCheckBox" />
<input type="checkbox" name="sports" value="sports" class="storesCheckBox" />
and my stores data is
// my stores
var stores = [
{
id: 1,
store: 'Store 1',
storeType: "shoes"
},
{
id: 2,
store: 'Store 2',
storeType: "clothes"
},
{
id: 3,
store: 'Store 3',
storeType: "sports"
},
{
id: 4,
store: 'Store 3',
storeSells: "shoes"
}
]
So, If I check shoes checkbox, I want to filter the data based on storeType shoes. So I wrote
var getStores = stores.filter(function (store) {
return store.storeType === 'shoes';
});
But Now, if I check clothes and shoes is already checked. I want to filter shoes + clothes data. And If I uncheck, shoes again I want to filter only clothes data. It can be any number of checkboxes depending on the store type. can you please help me out with this?
filteruseincludesmethod.