Foros del Web » Programando para Internet » Javascript »

Ayuda orden de pedido

Estas en el tema de Ayuda orden de pedido en el foro de Javascript en Foros del Web. estoy haciendo una orden de pedido para una empresa de remeras en javascript y tengo el sig problemita..agradeceria mucho que me puedan ayudar ya que ...
  #1 (permalink)  
Antiguo 27/09/2009, 13:21
 
Fecha de Ingreso: septiembre-2009
Mensajes: 40
Antigüedad: 14 años, 8 meses
Puntos: 0
Ayuda orden de pedido

estoy haciendo una orden de pedido para una empresa de remeras en javascript y tengo el sig problemita..agradeceria mucho que me puedan ayudar ya que soy muy limitado en programacion.. al grano..

la pagina carrito.htm consta de un formulario en donde para hacer un pedido se necestia poner la cantidad y q talle de remera el cliente va a pedir y apretando el boton Agregar manda todos los datos a estado.htm...

en estado.htm se puede ver el detalle de lo que el cliente agrego y aparece lo sig
Producto/Cantidad /Costo x unidad /Costo total ..
yo necesitaria agregar un ITEM TALLE

creo q el error esta en la funcion "buyItem" del archivo carrito.htm yo intente con agregarle newTalle y no me funciono

intente de mil formas y no tube suerte ..bueno espero que me puedan ayudar ..desde ya mil gracias


carrito.htm
<html>
<head>
<script language="JavaScript">
Código:
function cambiarTalle()
{
  
  document.itemsform.text3.value = 
     document.itemsform.newTalle.options [document.itemsform.newTalle.selectedIndex].value; 

 document.itemsform.text2.value = 
     document.itemsform.newTalle.options[document.itemsform.newTalle.selectedIndex].text;
	 
 }
</script>

</head>
<body >
Código:
<SCRIPT LANGUAGE="JavaScript">

	function buyItem(newItem, newPrice, newQuantity, newTalle) {
		if (newQuantity <= 0) {
			rc = alert('La cantidad ingresada es incorrecta');
			return false;
		}
		if (confirm('¿Agregar '+newQuantity+' '+newItem+' '+newTalle+' 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.substring(countbegin, countend)+"["+newItem+","+newTalle+","+newPrice+"#"+newQuantity+"]";
		}
		return true;
	}

	function resetShoppingBasket() {
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket=.";
	}
	
</SCRIPT>
Código:
<form NAME="itemsform">
       
              art352
        <input TYPE="value" NAME="agregar1" VALUE="1"SIZE="3">    
        <input type="text" name="text3" style="border:0;">
        <input type="text" name="text2" style="border:0;">	         
<select size="1" name="newTalle" ONCHANGE="cambiarTalle()">
            <option value="0">Talle...</option>
            <option value="30">T8</option>
            <option value="31">T10</option>
            <option value="32">T12</option>
			 </select></td>
 <td width="70" valign="top"><input type="button" name="cbtadd" value="Agregar"onClick="buyItem('art352',document.itemsform.newTalle.value,document.itemsform.agregar1.value,document.itemsform.text2.value)">
</td>
</body>
</html>


estado.htm
Código:
Código HTML:
<html>
<title>Estado del Carrito</title>
<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="150"><b>Producto</b></TD><TD width="50"><b>Talle</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>'+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=4><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>
    
<SCRIPT LANGUAGE="JavaScript">
	showItems();
</SCRIPT>
</html> 
  #2 (permalink)  
Antiguo 28/09/2009, 02:44
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 2 meses
Puntos: 574
Respuesta: Ayuda orden de pedido

Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript"> 
function cambiarTalle()
{
  
  document.itemsform.text3.value = 
     document.itemsform.newTalle.options [document.itemsform.newTalle.selectedIndex].value; 

 document.itemsform.text2.value = 
     document.itemsform.newTalle.options[document.itemsform.newTalle.selectedIndex].text;
	 
 }
 </script>
</head>

<body>
<SCRIPT LANGUAGE="JavaScript">

	function buyItem(newItem, newPrice, newQuantity, newTalle) {
		if (newQuantity <= 0) {
			rc = alert('La cantidad ingresada es incorrecta');
			return false;
		}
		if (confirm('¿Agregar '+newQuantity+' '+newItem+' '+newTalle+' 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.substring(countbegin, countend)+"["+newItem+","+newTalle+","+newPrice+"#"+newQuantity+"]";
		}
		return true;
	}

	function resetShoppingBasket() {
		index = document.cookie.indexOf("TheBasket");
		document.cookie="TheBasket=.";
	}
	
</SCRIPT>
<form NAME="itemsform">
         art352
		 <input name="producto" type="hidden" id="producto" value="art352">
        <input TYPE="value" NAME="agregar1" VALUE="1"SIZE="3">    
        <input type="text" name="text3" style="border:0;">
        <input type="text" name="text2" style="border:0;">	         
<select size="1" name="newTalle" ONCHANGE="cambiarTalle()">
            <option value="0">Talle...</option>
            <option value="30">T8</option>
            <option value="31">T10</option>
            <option value="32">T12</option>
			 </select><br>
<input type="button" name="cbtadd" value="Agregar" onClick="buyItem(document.itemsform.producto.value,
                                                                     document.itemsform.newTalle.value,
																	 document.itemsform.agregar1.value,
																	 document.itemsform.text2.value)">

</body>
</html> 
Código HTML:
<html>
<title>Estado del Carrito</title>
<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() {
        var theitem="";
		var thetalle="";
		var thequantity="";
		var theprice="";
		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="150"><b>Producto</b></TD><TD width="50"><b>Talle</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>'+thetalle+'</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>');
theitem="";
thetalle="";
			
            } else if (fulllist.substring(i,i+1) == ',' && theitem=="" && thetalle=="") {
				theitem = fulllist.substring(itemstart, i);
				itemstart = i+1;			
            } else if (fulllist.substring(i,i+1) == ',' && thetalle=="") {
				thetalle = 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=4><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>
    
<SCRIPT LANGUAGE="JavaScript">
	showItems();
</SCRIPT>
</html> 
A ver si descubres que he cambiado....

Un consejo llama a las cosas por su nombre y no hagas cosas como esta....

buyItem(newItem, newPrice, newQuantity, newTalle)

buyItem("art352",document.itemsform.newTalle.value ,document.itemsform.agregar1.value,document.itemsf orm.text2.value)

newItem="art352" OK
newPrice=document.itemsform.newTalle.value !!!
newQuantity=document.itemsform.agregar1.value !!!
newTalle=document.itemsform.text2.value !!!

el precio en el value del talle??

Quim
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 10:03.