Foros del Web » Programando para Internet » Javascript »

ayuda por favor carrito de compras!

Estas en el tema de ayuda por favor carrito de compras! en el foro de Javascript en Foros del Web. estoy tratando de armar un carrito de compras hecho en javascripts que se compone de la siguiente manera 1 archivo carrito.htm 1 archivo estado.htm 1 ...
  #1 (permalink)  
Antiguo 03/09/2009, 18:10
 
Fecha de Ingreso: septiembre-2009
Mensajes: 40
Antigüedad: 14 años, 7 meses
Puntos: 0
ayuda por favor carrito de compras!

estoy tratando de armar un carrito de compras hecho en javascripts que se compone de la siguiente manera

1 archivo carrito.htm
1 archivo estado.htm
1 archivo formulario
1 archivo enviar.pl

el archivo carrito.htm
en el cual se encuentran los sig. items

modelo/articulo/Precio/unidades

en donde el cliente pone las unidades que quiere del modelo y apretando el boton "agregar"
me manda los resultados a estado.htm donde se suma el costo total..
hasta ahi todo barbaro el tema es que tengo que agregar como item TALLES MEDIANTE UN CHECKBOX se me ocurre o si alguin me puede dar alguna otra solucion bienvenida sea.
quiero agregarlos siguientes talles 2/4/6/8/10/12/curva..

como puedo hacer para que ademas de las unidades me tome los datos que marco de los talles en el checkbox y me los pase al archivo estado.htm???

este es el archivo carrito.htm
<html>
<head>
<script LANGUAGE="JavaScript">
<!--
function CargarFoto(img, ancho, alto){
derecha=(screen.width-ancho)/2;
arriba=(screen.height-alto)/2;
string="toolbar=0,scrollbars=1,location=0,statusba r=0,menubar=0,resizable=1,width="+ancho+",height=" +alto+",left="+derecha+",top="+arriba+"";
fin=window.open(img,"",string);
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF" link="#32468D" vlink="#800080" class="body">
<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+' al carrito?')) {
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.subst ring(countbegin, countend)+"["+newItem+","+newPrice+"#"+newQuantity+"]";
}
return true;
}

function resetShoppingBasket() {
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket=.";
}
</SCRIPT>
<td width="127" valign="top" align="center"><a href="javascript:CargarFoto('imagenes/casiangeles.JPG','452','572')"><img src="thumbnails/foto.jpg" alt="d" width="89" height="100" border="0"></a></td>
<p>
<input type="button" name="cbtadd3" value="Agregar"
onClick="buyItem('saa','1', document.itemsform.agregar1.value)">
</p>
</div></td>
<td width="21" align="center" valign="top">1</td>
<td width="26" valign="top" align="center"><input TYPE="value" NAME="agregar1" VALUE="1"
SIZE="3"> </td>
<td width="55" valign="top" align="center">&nbsp;</td>
</tr>
</table>

<script language="JavaScript">

var NS4 = (document.layers);
var IE4 = (document.all);
var win = window; // Con frames usar top.nombre.window;
var n = 0;

function BuscarPalabras(str)
{
var txt, i, found;
if (str == "")
return false;

if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;

// No se encuentra en ninguna parte y envia un mensaje.
if (n == 0)
alert("No se encuentra.");
}

if (IE4) {
txt = win.document.body.createTextRange();
// Encuentra la coinsidencia desde el inicio de pagina.
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}

// Si lo encuentra, marca el resultado y mueve la barra de desplazamiento
// para mostrarlo.
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
// De otra manera regresa al inicio de la página para buscar otra coinsidencia
else {
if (n > 0) {
n = 0;
BuscarPalabras(str);
}
// No se encuentra en ninguna parte envia un mensaje.
else
alert("No se encontró.");
}
}
return false;
}
</script>
<Br>
<script language=JavaScript>document.write(window.screen.w idth+ " x "+window.screen.height)
</script>
<table border="0" cellpadding="0" cellspacing="0" width="640" class="body">
<tr>
<td width="100%" colspan="2">
<hr size="1" color="#000000">
</td>
</tr>
<tr>
<tr>
<td width="50%"></td>
<td width="50%" align="right">Página [<a href="carrito.htm">1</a>]</td>
</tr>
</table>
</center>
</body>
</html>


este es el archivo estado.htm
<html>
<head>
<title>Estado del Carrito</title>
</head>
<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><table border="1" cellspacing="0" width="640" bgcolor="#E0E0E0" bordercolor="#FFFFFF" class="td">');

document.writeln('<TR><TD width="250"><b>Producto</b></TD><TD width="80" align="right"><b>Cantidad</b></TD><TD width="120" align="right"><b>Costo x unidad</b></TD><td width="100" align="right"><b>Costo total</b><TD width="90">&nbsp;</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=right>'+thequantity+'</td><td align=right>'+theprice+'</td><td align=right>'+alterError(itemtotal)+'</td><td align=center><input TYPE="button" 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=right>'+alterError(totprice)+'</td><td>&nbsp;</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.htm";
}

function clearBasket() {
if (confirm('¿Confirma que desea reestablecer el carrito?')) {
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket=.";
top.location = "estado.htm";
}
}
</SCRIPT>
<body bgcolor="#FFFFFF" link="#32468D" vlink="#800080" class="body">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="640" class="body">
<tr>
<td width="50%"><big><big>Estado del Carrito</big></big></td>
<td width="50%" align="right">[ <a href="carrito.htm">Carrito de Compra</a> | Estado | <a href="formulario.htm">Formulario</a> ]</td>
</tr>
<tr>
<td width="100%" colspan="2">
<hr size="1" color="#000000">
</td>
</tr>
<tr>
<td width="100%" colspan="2"></td>
</tr>
</table>
<br>
<SCRIPT LANGUAGE="JavaScript">
showItems();
</SCRIPT>
<br>
<table border="0" cellpadding="0" cellspacing="0" width="640" class="body">
<tr>
<td width="100%" colspan="2">
<hr size="1" color="#000000">
</td>
</tr>
<tr>
<td width="50%"></td>
<td width="50%" align="right">[ <a href="javascript:clearBasket()">Reestablecer
Carrito</a> ]</td>
</tr>
</table>

</center>
</body>
</html>
  #2 (permalink)  
Antiguo 03/09/2009, 19:36
Avatar de uselox  
Fecha de Ingreso: agosto-2008
Ubicación: Lima, Perú
Mensajes: 168
Antigüedad: 15 años, 7 meses
Puntos: 12
Respuesta: ayuda por favor carrito de compras!

Hola juanitoto :

hasta donde sé es imposible hacer un carrito de compras en javascript.
te suguiero que uses algun lenguaje de servidor.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:03.