Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I When the check box and check box ios true Android OS products will be displayed.
Thank.
JavaScript
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();
     });

});
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900