Salve a tutti scrivo per chiedervi un aiuto.

Sto lavorando su un carrello della spesa fatto in javascript in cui tutti i prodotti aggiunti al carrello vengono salvati su un cookie e ripresi ogni volta da lì.

Nell'ultima pagina ( quella del check out ) ho la necessità di trasformare le variabili da javascript a php e questo lo faccio con dei campi hidden da pagina check out alla pagina successiva.

Ma se per caso i prodotti comprati sono più di uno come faccio a passare tutto l'elenco completo degli articoli nel carrello alla pagina successiva? io credo venga usato una sorta di array.

Qui sotto c'è il codice

########inizio codice########

<SCRIPT language="JavaScript">
<!--

function showBasket() {

index = document.cookie.indexOf("TheBasket");

countbegin = (document.cookie.indexOf("=", index) + 1);

countend = document.cookie.indexOf(";", index);

if (countend == -1) {

countend = document.cookie.length;

}

fulllist = document.cookie.substring(countbegin, countend);

totprice = 0;







document.writeln('<form action="pippo.php" method="POST">');
document.writeln('<INPUT NAME="mer_id" TYPE="hidden" VALUE="999999">');
document.writeln('<INPUT NAME="mer_url_idx" TYPE="HIDDEN" VALUE="1">');
document.writeln('<INPUT NAME="deferred_entry" TYPE="HIDDEN" VALUE="1">');
document.writeln('<INPUT NAME="num_items" TYPE="hidden" VALUE="100">');




document.writeln('<TABLE BORDER=1 cellpadding=2 cellspacing=0>');

document.writeln('<TR><TD>Item</TD><TD>Quantity</TD><TD>Cost Each</TD><td>Total Cost (US$)</td></TR>');




itemlist = 0;

for (var i = 0; i <= fulllist.length; i++) {

if (fulllist.substring(i,i+1) == '[') {

thisitem = 1;

itemstart = i+1;

} else if (fulllist.substring(i,i+1) == ']') {

itemend = i;

thequantity = fulllist.substring(itemstart, itemend);

itemtotal = 0;

itemtotal = (eval(theprice*thequantity));

temptotal = itemtotal * 100;

totprice = totprice + itemtotal;

itemlist=itemlist+1;

document.write('<tr><td>'+theitem+'
' + thetype+'</td>');





document.writeln('<td align=right>'+thequantity+'</td>');





document.writeln('<td align=right>$'+theprice+'</td>');

document.writeln('<td align=right>$'+alterError(itemtotal)+'</td>');

document.writeln('<td align=center></td>');





if (thecolid=='NONSTD') {

itemdesc = theitem; }

else {

// itemdesc = theitem+', Type: ' + thecolid+ ' - ' + thetype

itemdesc = theitem+', Type: ' + thetype

}

document.writeln('<INPUT TYPE="hidden" NAME="item'+itemlist+'_desc" VALUE="'+itemdesc+'">');

document.writeln('<INPUT TYPE="hidden" NAME="item'+itemlist+'_qty" VALUE="'+thequantity+'">');

document.writeln('<INPUT TYPE="hidden" NAME="item'+itemlist+'_price" VALUE="'+theprice+'">');

document.writeln('<INPUT TYPE="hidden" NAME="total cost'+itemlist+'" VALUE="'+alterError(itemtotal)+'">');



document.writeln('</tr>');



} else if (fulllist.substring(i,i+1) == '|') {

if (thisitem==1) theitem = fulllist.substring(itemstart, i);

if (thisitem==2) thecolid = fulllist.substring(itemstart, i);

if (thisitem==3) thetype = fulllist.substring(itemstart, i);

if (thisitem==4) theprice = fulllist.substring(itemstart, i);

thisitem++;

itemstart=i+1;

}

}

document.writeln('<tr><td colspan=3>Total Cost (US dollars)</td><td align=right>$'+alterError(totprice)+'</td>');

document.writeln('<td align=center></td>');





document.writeln('</tr>');

document.writeln('<INPUT TYPE="hidden" NAME="Goods Total" VALUE="'+alterError(totprice)+'">');

document.writeln('</TABLE>');

document.writeln('
Cookies <U>must</U> be enabled in your browser.
If they are not, you will be unable to use the shopping basket.
');

}





// ExRates - show exchange rates

function ExRates(value) {

msg=window.open("exrates.asp?rate="+value,"_blank" ,"toolbar=no,width=600,height=400,directories=no,s tatus=no,scrollbars=yes,resize=yes,menubar=no");

#### fine codice ###

Spero possiate aiutarmi in qualche modo.

Ringrazio anticipatamente