选择2组产品 [英] Select 2 group of products
本文介绍了选择2组产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I当显示复选框和复选框ios true时,将显示Android OS产品。
感谢。
I When the check box and check box ios true Android OS products will be displayed.
Thank.
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();
});
});
推荐答案
.each(products,函数(i,object){
var curentPrice = parseFloat (对象。价格);
var priceMinOk = true ;
var priceMaxOk = true ;
// 过滤结果与价格范围匹配
if (maxPrice || minPrice){
if (maxPrice&& maxPrice< curentPrice){
priceMaxOk = false ;
}
if (m inPrice&& minPrice> curentPrice){
priceMinOk = false ;
}
}
// 循环列表并获取仅与新数组相关
如果(priceMinOk&& priceMaxOk){
if (os == android || os == ios)
{
if (object。 os == os)
{
filterdProducts [key] = object;
key ++;
}
}
else
{
filterdProducts [key] = object;
key ++;
}
}
});
}
.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 (){
})
(document).ready(function() { })
(' #os' )。change( function (){
if (
('#os').change(function(){ if (
这篇关于选择2组产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文