Armé una carrito de compras con un asistente que genera todo el codigo en javascript. Necesito enviar todo el contenido que queda guardado en una cookie por e-mail, preferiblemente con php que es lo que manejo mejor.
este es el script que imprime el contenido:
Código HTML:
<SCRIPT LANGUAGE="JavaScript">
<!--
function Enviar(form) {
for (i = 0; i < form.elements.length; i++) {
if (form.elements[i].type == "text" && form.elements[i].value == "") {
alert("Por favor complete todos los campos del formulario"); form.elements[i].focus();
return false; }
}
form.submit();
}
// -->
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" link="#3F3F3F" vlink="#6F6F6F" class="body">
<SCRIPT LANGUAGE="JavaScript">
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);
}
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 target="carrito"><table border="1" cellspacing="0" width="370" bgcolor="#E0E0E0" bordercolor="#FFFFFF" class="td">');
document.writeln('<TR><TD width="30%"><b>Producto</b></TD><TD width="20%" align="right"><b>Cantidad</b></TD><TD width="20%" align="right"><b>Costo x unidad</b></TD><td width="20%" align="right"><b>Costo total</b></TR>');
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+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;
var tax = itemtotal / 100 * (0 - 0);
tax = Math.floor(tax * 100)/100
totprice = totprice + itemtotal + tax;
itemlist=itemlist+1;
document.writeln('<tr><td>'+theitem+'</td><td align=right>'+thequantity+'</td><td align=right>'+theprice+'</td><td align=right>'+alterError(itemtotal)+'</td></tr>');
} else if (fulllist.substring(i,i+1) == ',') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == '#') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}
document.writeln('<tr><td colspan=3><b>Total</b></td><td align=right>'+alterError(totprice)+'</td></tr>');
document.writeln('</TABLE>');
}
function Total() {
document.writeln(alterError(totprice));
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
showItems();
</SCRIPT>
Gracias anticipadas.