print_r($getPrice)
result is:the elements $getPrice contains is not know, it can 1 or 2 or like the following(3 elements)
Array
(
[0] => Array
(
[price_qty] => 2
[price] => 100.0000
)
[1] => Array
(
[price_qty] => 5
[price] => 90.0000
)
[2] => Array
(
[price_qty] => 8
[price] => 80.0000
)
)
the jquery code:get all the input value and make an addition
$(document).ready(function() { //wrap in a document.ready event handler
$('input').on('keyup', function() {
var result = 0;
$('.liste_couleur_qty li input').each(function() {
result += parseInt(this.value, 10);
});
$('div#qtyvalue').text(result);
});
});
now, I want to get compare the result with [price_qty]
from the $getPrice
array. if the result less than 0,then using the result multiply the [price] (from the $getPrice array) value.
eg:
if result(from the jquery code) < 2, then price= result*110. then $('div#qtyvalue').text(result); change to $('div#qtyvalue').text("the qty is "+result+" the price is "+price);
if between 2--5(contain 5), the price is 100. if between 5--8(not contain 8), the price is 90
How to do it? Thank you.
Is there a way to put the php array into a javascript array and then make the compare?