title: store values in variable depending on input values
body: <p>I have the following code, and what I want to do is store the dataids in the array dataids depending on the packageid and categoryid, these two value are defined in packageBtnFilter and categoryBtnFilter. If they are both 0 then it should return all the dataids in the list. At the moment if you see it only stores the dataids of all items with packageids equal to three but it should not depend on packageBtnFilter and categoryBtnFilter.</p>
  
  <pre><code>var store_products = function () {
                var catalogue = new Array();
                var packageBtnFilter = $('#packages').val();
                var categoryBtnFilter = $('#categories').val();   
  
                $('ul.list').each(function () {
                  var localproducts = new Array();
                  $(this).find('li').each(function () {
                    var $itm = $(this);
                    localproducts.push({
                      'dataid': $itm.attr('data-id'),
                        'datapackage': $itm.attr('data-package'),
                        'packageid': ($itm.children('.packageid').text()),
                                        'categoryid': ($itm.children('.packageid').text())
                    });
  
                    catalogue.push(localproducts[localproducts.length - 1]);
                  });
  
                  var dataids = new Array();
  
                  $(catalogue).each(function () {
  
                    if (this.packageid == 3) dataids.push(this.dataid);
                  });
  
  
              console.log(dataids);
  
                });
  
  
  
      }
  
      store_products();
  </code></pre>
  
  <p>Thanks!</p>
  
  <p><a href="http://jsfiddle.net/hunter/Tcwgf/1/" rel="nofollow">http://jsfiddle.net/hunter/Tcwgf/1/</a></p>