Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  23] [ 6]  / answers: 1 / hits: 54054  / 12 Years ago, thu, may 17, 2012, 12:00:00

Here's my script :


function itemQuantityHandler(operation, cart_item) {
var v = cart_item.quantity;

//add one
if (operation === 'add' && v < settings.productBuyLimit) {
v++;
}

//substract one
if (operation === 'subtract' && v > 1) {
v--;
}

//update quantity in shopping cart
$('.item-quantity').text(v);

//save new quantity to cart
cart_item.quantity = v;
}

What I need is to increase v (cart_item.quantity) by more than one. Here, it's using v++, but it's only increasing by 1. How can I change this to make it increase by 4 every time I click on the plus icon?


I tried


v++ +4

But it's not working.


More From » increment

 Answers
7

Use a compound assignment operator:



v += 4;

[#85512] Wednesday, May 16, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lara

Total Points: 462
Total Questions: 100
Total Answers: 102

Location: Jersey
Member since Mon, Jun 14, 2021
3 Years ago
lara questions
;