i there im creating a web store and got a problem that i cannot fix.
here it is:
got a cart with name, picture, quantity, price, etc. in the quantity i can delete or update, my problem is changing.
the user just click in buy hyperlink and send to the session the information of the product:
if ($_GET['encomendar'])
{
...
if (!$_SESSION['cesto'][$_GET['encomendar']])
{
$_SESSION['cesto'][$_GET['encomendar']]['quant'] = 1;
...
in the cart he gets everything from the session['cesto'] and show it
...
foreach($_SESSION['cesto'] as $cesto)
{
?>
. . .
<input name="quantidade_" id="quantidade_" type="text" value="<?php echo $cesto['quant']?>" />
<a onclick="submitFormPorGet(<?php echo $cesto['id'].$cesto['quant'];?>)" href="javascript:void(0)"><img src="imgs/refresh.jpg"></a>
. . .
and got the javascript where he get the id and quantity of the product:
<script language="javascript" type="text/javascript">
function submitFormPorGet(id)
{
var qtd = document.getElementById('quantidade_').value;
window.location='?marcar=' + id + '&quantidade_=' + qtd;
}
</script>
and the when he get encomendar he change the quantity
if($_GET['marcar']){
$_SESSION['cesto'][$_GET['marcar']]['quant'] = $_GET['quantidade_'];
}
i already text if he get the marcar(var_dump($_GET))
Array ( [marcar] => 21 [quantidade_] => 4 )
marcar is the same as id and quantidade is the same as quantidade_
after the refresh he create another line with no id and the quantity i wanted: