0
<script>
$(document).ready(function () {
$("input").change(function () {
var carrinho = $("#carrinho").val();
//alert("Carrinho " + carrinho);
var i;
var soma = 0;
for (i = 1; i <= carrinho; i++) {
//alert(i);
var x = $("#p" + i).val();
//alert(i+"---- "+x);
var y = $("#txt_p" + i).val();
//alert(i+ "------ "+y);
var z = $("#preco" + i).val();
//alert(i + "------ "+z);
var total = x * z;
//alert("Total = "+ total);
var atualiza = total;
//alert("Valor atualizado = "+ total);
soma = soma + total;
$("#txt_p" + i).text(atualiza + "€");
$("#total").text(soma + "€");
$("#teste" + i).val(x);
//a variavel x irá armazenar a quatidade atual do produto
<?php
$c = count($_SESSION["shopping_cart"]);
for ($k1 = 0; $k1 < $c; $k1++) {
$_SESSION["shopping_cart"][$k1]["item_quantity"] = x;
}
?>
}
});
});
</script>
There is no way to do this. If it were otherwise PHP -> Javascript would give, but JS -> PHP has no way.
– Sam
What you can do is send this information via ajax.
– Wictor Chaves
@Wictorchaves and how do I do it? by chance I never worked with ajax... :s
– Tiago Simoes
@Wictorchaves got it, buddy! I have already implemented your code in my project but still n updates the session variable because imagining that I change page and back again the amount values are the same when the user entered the product in your cart and n the new values of Qta that it introduced before leaving. that is, still my problem...
– Tiago Simoes
Try debugging by pressing F12
– Wictor Chaves