ok tengo los siguientes archivos:
catalogo.html
estado.html
formulario.html
enviar.php
cuando los archivos estan juntos en una sola carpeta, funcionan muy bien. Peroooo!!
cuando los coloco asi:
producto/catalogo.html
estado.html
formulario.html
enviar.php
no me vuelve a funcionar correctamente.
aqui dejo los codigos:
catalogo.html
Código HTML:
<SCRIPT LANGUAGE="JavaScript">
function buyItem(newItem, newPrice, newQuantity) {
if (newQuantity <= 0) {
rc = alert('La cantidad ingresada es incorrecta');
return false;
}
if (confirm('¿Agregar '+newQuantity+' '+newItem+' a la lista de consulta?')) {
index = document.cookie.indexOf("TheBasket");
countbegin = (document.cookie.indexOf("=", index) + 1);
countend = document.cookie.indexOf(";", index);
if (countend == -1) {
countend = document.cookie.length;
}
document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+","+newPrice+"#"+newQuantity+"]";
}
return true;
}
function resetShoppingBasket() {
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket=.";
}
</SCRIPT>
estado.html
Código HTML:
<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;
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><table border="1" cellspacing="0" width="640" bgcolor="#E0E0E0" bordercolor="#FFFFFF" class="texto4">');
document.writeln('<TR><TD width="250"><b>Productos</b></TD><TD width="80" align="center"><b>Cantidad</b></TD><TD width="120" align="center"><b>Costo x unidad</b></TD><td width="100" align="center"><b>Costo total</b><TD width="90"> </TD></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=center>'+thequantity+'</td><td align=center>'+theprice+'</td><td align=center>'+alterError(itemtotal)+'</td><td align=center><input TYPE="image" src="../img/quitar.png" NAME="remove" VALUE="Quitar" onclick="javascript:removeItem('+itemlist+')"></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=center><b>'+alterError(totprice)+'</b></td><td> </td></tr>');
document.writeln('</TABLE>');
}
function removeItem(itemno) {
newItemList = null;
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;
theitem = fulllist.substring(itemstart, itemend);
itemlist=itemlist+1;
if (itemlist != itemno) {
newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
}
}
}
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket="+newItemList;
top.location = "estado.html";
}
function clearBasket() {
if (confirm('¿Confirma que desea reestablecer el carrito?')) {
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket=.";
top.location = "estado.html";
}
}
</SCRIPT>
formulario.html
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>
<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;
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;
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('<INPUT TYPE="hidden" NAME="Producto'+itemlist+'" VALUE="'+theitem+'" SIZE="40">');
document.writeln('<INPUT TYPE="hidden" NAME="Cantidad'+itemlist+'" VALUE="'+thequantity+'" SIZE="40">')
document.writeln('<INPUT TYPE="hidden" NAME="ProductoTotal'+itemlist+'" VALUE="'+alterError(itemtotal)+'" SIZE="40">');
} 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('<INPUT TYPE="hidden" NAME="Total" VALUE="'+alterError(totprice)+'" SIZE="40">');
}
function Total() {
document.writeln(alterError(totprice));
}
</SCRIPT>
enviar.php
Código HTML:
<?
$MailToAddress = "[email protected]";
$MailSubject = "Cibertienda";
if (!$MailFromAddress) {
$MailFromAddress = "[email protected]";
}
$Header = "Civertienda v1.0 - Orden de Compra";
$Footer = "";
if (!is_array($HTTP_POST_VARS))
return;
reset($HTTP_POST_VARS);
while(list($key, $val) = each($HTTP_POST_VARS)) {
$GLOBALS[$key] = $val;
$val=stripslashes($val);
$Message .= "$key = $val\n";
}
if ($Header) {
$Message = $Header."\n\n".$Message."\n\n";
}
$Message .= "REMOTE HOST: ".$REMOTE_HOST."\n";
$Message .= "REMOTE USER: ". $REMOTE_USER."\n";
$Message .= "REMOTE ADDR: ". $REMOTE_ADDR."\n";
if ($Footer) {
$Message .= "\n\n".$Footer;
}
mail( "$MailToAddress", "$MailSubject", "$Message", "From: $MailFromAddress");
header ("Location: catalogo.html");
?>
Algo tiene q ver con las galletas, pero no logro encontrar el destino.
muy agradecido.