var filterdProducts = []; // displayed products array var key = 0; // if needed price range filter if (!minPrice && !maxPrice) { filterdProducts = products; } else{ $.each(products, function(i, object) { var curentPrice = parseFloat(object.price); var priceMinOk = true; var priceMaxOk = true; // filter results match the price range if(maxPrice || minPrice){ if(maxPrice && maxPrice<curentPrice){ priceMaxOk = false; } if(minPrice && minPrice>curentPrice){ priceMinOk = false; } } // loop over list and get only related to new array if (priceMinOk && priceMaxOk) { if (os == "android" || os=="ios") { if(object.os == os) { filterdProducts[key] = object; key++; } } else { filterdProducts[key] = object; key++; } } }); } $(document).ready(function() { }) $('#os').change(function(){ if ($(this).is(':checked')) os = "android"; else os = "no"; currentpage = 0; displayProducts(); }); $('#other').change(function () { if ($(this).is(':checked')) os = "ios"; else os = "no"; currentpage = 0; displayProducts(); }); });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)