PDA

View Full Version : سوال: نمایش با true شدن دو چکباکس



sadegh.te
یک شنبه 30 آذر 1393, 10:02 صبح
سلام من در کد زیر دو تا چکباکس دارم میخوام وقتی که چکباس اندرویید و ios فعال شد محصولاتی رو نمایش بده سیستم عاملشون اندروید و ios هستش. ولی این کد من فقط یک دسته از محصولات رو نمایش میده اگه میشه راهنمایی کنید. ممنون


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();
});

});