Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/05/2006, 10:16
edysierra
 
Fecha de Ingreso: febrero-2005
Mensajes: 86
Antigüedad: 19 años, 3 meses
Puntos: 1
Problemas con un cotizador

Hola a Todos!!
Ante todo quiero aclarar que no cuento con profundos conocimientos en java y por eso es que no puedo encontrarle la vuelta a un problema que tengo con un cotizador que he realizado a partir de un originalmente carrito de compras.
El asunto es que si bien funciona casi todo, hay dos cosas que no puedo saber donde tienen sus fallas: Una es que quiero que el detalle de los articulos que cotizaron aparezcan en algun campo en el formulario de manera que los pueda luego levantar desde la pagina ENVIAR.ASP para agregarlos a la BD y a la vez enviarlos por mail.
Y el otro problema es que si bien recibo por mail el o los articulos pedidos, tambien salen los que no se pidieron (repetidamente):
Producto:
Cantidad: en blanco desde luego...
Estas son las partes importantes de las tres primeras paginas. La de asp la coloco en otro post pq me la rechaza por que he hecho esto muy largo… disculpas….

art204.html (esta es la pagina del articulo en si mismo)

<html>
<head>
<title>Articulo 204</title>

</head>

<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 cotización?')) {
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+","+newQuantity+"]";
}
return true;
}

function resetShoppingBasket() {
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket=.";
}
</SCRIPT>
....
<input name="agregar1" type="value" id="agregar1" value="1"
...
<input type="button" name="cbtadd" value="Solicitar"
onClick="buyItem('ART204','5.00', document.itemsform.agregar1.value)">
</table>
</div></td>
<td><div align="center"><a href="estado.htm"><img src="arts/images/ver.gif" width="60" height="20"
border="0"></a>
</div></td>
<td><div align="center"><a href="formulario.htm</a>
</div></td>
</form>

</body>
</html>


estado.html (muestra el estado del cotizador)

<html>
<head>
<title>Estado del Pedido</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="4" width="350" bgcolor="#708090" bordercolor="#FFFFFF"
class="td">');

document.writeln('<TR><TD width="80" align="center"><b>Artículo</b></TD><TD width="80" align="center"><b>Cantidad</b></TD><TD
width="80" align="center"><b>Modificar</b></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><input TYPE="button"
NAME="remove" VALUE="Eliminar" 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 pedido?')) {
index = document.cookie.indexOf("TheBasket");
document.cookie="TheBasket=.";
top.location = "estado.htm";
}
}
</SCRIPT>

<table width="485" border="0" align="center" cellpadding="0" cellspacing="0" class="body">
<tr>
<td width="50%"><font color="#000000">Estado de su Pedido</font></td>
<td width="50%" align="right"><font color="#000000"><a href="javascript:window.close()">Continuar Cotizando</a></font>| |<a href="formulario.asp"><font color="#000000">Cerrar Pedido</font></a></td>
</tr>

<SCRIPT LANGUAGE="JavaScript">
showItems();
</SCRIPT>
<br>
<tr>
<td width="100%" colspan="2">
<hr size="1" color="#FFFFFF">
</td>
</tr>
<tr>
<td width="50%"></td>
<td width="50%" align="right">[<font color="#000000"> <a href="javascript:clearBasket()">Reestablecer
Pedido</a> ]</font></td>
</tr>
</table>
</center>
</body>
</html>



formulario.html (el form para que introduzca todos los datos del cliente)

<html>
<head>
<title>Formulario de Cotizacion</title>

<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();
}
// -->

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></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;

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(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>

<center>
<FORM method="post" action="enviar.asp" target="_top">
//AQUI SIGUE EL DESARROLLO DEL FORMULARIO


<SCRIPT LANGUAGE="JavaScript">
showItems();
</SCRIPT>

<td> <input name="enviar" type="submit" id="enviar" value="Enviar"> <input type="reset" value="Restablecer">
</td>
</form>
</body>
</html>