var model = [];
$('.glyphicon-plus').click(function() {
var product_id = $('#productSelect').val();
var size_id = $('#sizeSelect').val();
var colour_id = $('#colourSelect').val();
var quantity = $('#quantity').val();
if(i = subFilter(model, "product_id", product_id) !== false) {
if(i = subFilter(model, "size_id", size_id) !== false) {
if(i = subFilter(model, "colour_id", colour_id) !== false) {
console.log(model);
model[i].quantity = quantity;
}
}
}
model.push({
product_id: product_id,
size_id: size_id,
colour_id: colour_id,
quantity: quantity
});
subFilter(model, "product_id", product_id);
console.log(model)
});
function subFilter(object, paramName, paramValue) {
$.each(object, function(i, v){
if(v[paramName] == paramValue) {
return i;
}
});
$('.glyphicon-plus').click(function() {
var product_id = $('#productSelect').val();
var size_id = $('#sizeSelect').val();
var colour_id = $('#colourSelect').val();
var quantity = $('#quantity').val();
if(i = subFilter(model, "product_id", product_id) !== false) {
if(i = subFilter(model, "size_id", size_id) !== false) {
if(i = subFilter(model, "colour_id", colour_id) !== false) {
console.log(model);
model[i].quantity = quantity;
}
}
}
model.push({
product_id: product_id,
size_id: size_id,
colour_id: colour_id,
quantity: quantity
});
subFilter(model, "product_id", product_id);
console.log(model)
});
function subFilter(object, paramName, paramValue) {
$.each(object, function(i, v){
if(v[paramName] == paramValue) {
return i;
}
});
No comments:
Post a Comment