I have an array called catalogue which holds 4 items:
packageid, dataid , categoryid and datapackage.
What I want to do is push into the array dataids all the dataids of items whose packageid is equal to packageBtnFilter and whose categoryid is equal to categoryBtnFilter. If the value of packageBtnFilter and categoryBtnFilter are both 0 then it should push all the dataids of catalogue into the dataids array. At the moment it just pushes the dataids of items whose packageid is equal to 3.
var packageBtnFilter = $('#packages').val();
var categoryBtnFilter = $('#categories').val();
var dataids = new Array();
$(catalogue).each(function () {
if (this.packageid == 3) dataids.push(this.dataid);
});
Thanks!
the full code is here
http://jsfiddle.net/hunter/Tcwgf/1/
Use the filter function to filter the result and map to get the ids: