2
print_r($getPrice)
結果爲:$用getPrice包含不知道的元素,它可以1或2或類似下面的(3片)如何使用php輸出並在jQuery中進行比較?
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
)
)
jQuery代碼: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);
});
});
現在,我想要得到的結果與[price_qty]
從$getPrice
陣列進行比較。如果結果小於0,則使用結果乘以[price](來自$ getPrice數組)的值。
如:
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
怎麼辦呢?謝謝。
是否有把PHP數組轉換成JavaScript數組,然後進行比較的方法嗎?
解析它在jQuery的我不知道該怎麼辦/。你可以給我更多的details.many感謝 – stackoverflow002
@ stackoverflow002:請查看更新的答案.. – mithunsatheesh
元素$用getPrice包含不知道,它可以1或2或其他 – stackoverflow002