jquery - Building a dynamic if or statement in javascript for use as a filter -


i'm looping through object keys in firebase database checking property myfirebaseobject.category specific category. have multiple filters stacked. if checkbox checked want include objects associated category , combine them other selected categories in new array.

i'm not looking code unless it's best way explain approach. i'm trying learn i'm thinking more conceptually: "what best approach building stackable filters using checkboxes in javascript"

is there way dynamically build if statement(assuming 1 , 3 checked)?

if statement:

if (myfirebaseobject.category === '1' || myfirebaseobject.category === '3' && myfirebaseobject.enabled === '1'){//populate array}; 

my checkboxes:

<input id="cat1" class="category_check" type="checkbox" checked="true" name="filter" value="1" >1<br> <input id="cat2" class="category_check" type="checkbox" name="filter" value="2">2<br> <input id="cat3" class="category_check" type="checkbox" checked="true" name="filter" value="3">3<br> <input id="cat4" class="category_check" type="checkbox" name="filter" value="4">4<br> 

instead of dynamic if statement, use array. can check see if item in array easily.

see: javascript in array


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -