JSON Object Multiple filter

Viewed 1683

I have JSON object in which data gets filter on Selecting elements from form. My form has following elements:

Min Age - Max Age and Gender - male(1) & female(2)

Following is my JSON object:

[
   {
      "id":"1",
      "name":"nehil",
      "gender":"1",
      "birthday":"1991-07-22",
      "business_id":"1",
      "timestamp":"2016-03-23 04:46:42",
      "age":"24"
   },
   {
      "id":"2",
      "name":"vartika ",
      "gender":"2",
      "birthday":"1990-08-14",
      "business_id":"1",
      "timestamp":"2016-03-23 04:46:46",
       "age":"25"
   },
   {
      "id":"3",
      "name":"atharva",
      "gender":"1",
      "birthday":"1992-10-10",
      "business_id":"1",
      "timestamp":"2016-03-23 04:46:49",
       "age":"23"
   },
   {
      "id":"4",
      "name":"karan",
      "gender":"1",
      "birthday":"1992-12-22",
      "business_id":"1",
      "timestamp":"2016-03-23 04:46:52",
      "age":"23"
   }
]

On Gender select if male, I want id of all males from the object and push it in array. Later if I select min age as 23 and max age as 24, I want all males with following age to be updated in that array.

What will be best strategy to achieve this?

Following is my fiddle link - http://jsfiddle.net/Nehil/2ym3ffo0/4/

2 Answers
Related