Værdier
HejJeg har denne kode (kurv til en webshop)...
Jeg skal have værdierne sendt vidre til en php mail form.
Mit problem er at hvis der er mere end 1 produkt i kurven så ved jeg ikke hvordan jeg får de andre værdier...
Jeg har haft det tik at virke med et formmail script i perl... der viste den sådan her:
Artikel: En varer1., En varer2., En varer3.
Men hvordan får jeg de værdier??? frem på min mail form i php...?
Jeg har det til at virke med en varer med dette:
$Artikel,$Antal,$Pris/stk
HJÆLP!
<SCRIPT language=JavaScript>
// alterError - fixes a rounding bug in Netscape 2
function alterError(value) {
if (value<=0.99) {
newPounds = '0';
} else {
newPounds = parseInt(value);
}
newPence = parseInt((value+.0008 - newPounds)* 100);
if (eval(newPence) <= 9) newPence='0'+newPence;
newString = newPounds + '.' + newPence;
return (newString);
}
// showItems () - creates a table of items in the basket and
// creates the start of a form which sets information for
// basket items.
function showItems() {
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 NAME="BUY" action="mail.php" METHOD=POST>');
document.writeln('<input type="hidden" name="recipient" value="EMAIL@EMAIL:DK">');
document.writeln('<input type="hidden" name="subject" value="online bestilling">');
document.writeln('<input type="hidden" name="redirect" value="DOMÆNE:DK">');
document.writeln('<TABLE width="460" BORDER=0 CELLPADDING=1 CELLSPACING=1 background="filer/bagg2.gif">');
document.writeln('<TR><TD width="240"><b><font size="2" FACE="Verdana" COLOR="#ffffff"">Artikel</font></b></TD><TD width="70"><b><font size="2" FACE="Verdana" COLOR="#ffffff""> Antal</font></b></TD><TD width="70"><b><font size="2" FACE="Verdana" COLOR="#ffffff""> kr/stk</font></b></TD><td width="70" align="right"><b><font size="2" FACE="Verdana" COLOR="#ffffff"">kr total</font></b></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><FONT SIZE="2" FACE="verdana">'+theitem+'</td>');
document.writeln('<td align=left><FONT SIZE="2" FACE="verdana"> '+thequantity+'</td><td align=left><FONT SIZE="2" FACE="verdana">'+theprice+'</td><td align=right><FONT SIZE="2" FACE="verdana"> '+alterError(itemtotal)+'</td></tr>');
document.writeln('<INPUT TYPE="hidden" NAME="Artikel" NAME="Artikel '+itemlist+'" VALUE="'+theitem+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="Antal" NAME="Antal '+itemlist+'" VALUE="'+thequantity+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="Pris/stk" NAME="Pris/stk '+itemlist+'" VALUE="'+theprice+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="Total" NAME="Total'+itemlist+'" VALUE="'+alterError(itemtotal)+'" SIZE="40">');
} else if (fulllist.substring(i,i+1) == '|') {
if (thisitem==1) theitem = fulllist.substring(itemstart, i);
if (thisitem==2) theprice = fulllist.substring(itemstart, i);
thisitem++;
itemstart=i+1;
}
}
document.writeln('<tr><td background="filer/bagg3.gif" colspan=3><b><FONT SIZE="2" FACE="verdana" COLOR="Black">Kr. total excl. fragt*.</FONT></b></td><td align=right background="filer/bagg3.gif"><FONT SIZE="2" FACE="verdana" COLOR="Black"><b>'+alterError(totprice)+'</b></td></tr>');
document.writeln('<INPUT TYPE="hidden" NAME="Varer Total" VALUE="'+alterError(totprice)+'" SIZE="40">');
document.writeln('</TABLE>');
}
</SCRIPT>
<p align="left"><script LANGUAGE="JavaScript">
showItems();
</script> </p>