He decidido levantarme de la tumba en mi existencia en Cristalab y volverla hacer parte de mi vida como lo era antes, y para comenzar vengo necesitando de su ayuda.
Sufro ahora mismo de una "ceguera de túnel" o "frustración" por verlo tantas veces pero me es imposible dar con la solución a este problema que tal vez será muy sencillo o no, y por ello recurro a ustedes.
El problema:
Diseño un formulario de pedido en línea para un proyecto donde creé un formulario con "autosuma" que suma los valores de los productos y los multiplica por la cantidad que el cliente pida de los mismos y al final de la página le da un "total" del pedido, pero soy incapaz de terminar de mandar ese valor "total" del pedido junto con el registro de las cantidades a un correo, es decir no puedo encontrar el error o lo que me falta para enviar el pedido con la cantidad de producto y el total del mismo.
Aquí mi codigo:
Código :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="/js/lib/dummy.js"></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type="text/css">
</style>
<script type="text/javascript">
//<![CDATA[
window.onload=function(){
document.getElementById('test').onsubmit = function () {
// Obtener todos los 'input' dentro de este 'form'
var inputs = this.getElementsByTagName('INPUT');
// Preiniciar el variable 'total'
var total = 20;
// Hacer un bucle de todos los 'input'
for (var i = 0, inputsLength = inputs.length; i < inputsLength; i = i + 2) {
// Revisar si el 'input' actual es un 'checkbox' y si está marcado
if ('checkbox' == inputs[i].type && true == inputs[i].checked) {
// Sumar al total
total += parseInt(inputs[i].value) * parseInt(inputs[i + 1].value);
}
}
// Mostrar el total
document.getElementById('total').value = total;
// No enviar el formulario
return false;
};
}//]]>
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Formulario Prueba</title>
</head>
<body bgcolor="9c0217" text="#FFFFFF">
<center>
<font face="Arial, Helvetica, sans-serif">
<br />
<h2>¿Cúal será tu pedido?</h2>
<font size="1">
<form id="test">
<table border="0">
<tr>
<th colspan="2"><img src="jamonyqueso.png" / title="Rico pastie con jamón York y queso derretido"></th><th colspan="2"><img src="hawaiiano.png" / title="Delicioso Pastie con Piña en trozos, jamón York y queso derretido"></th></tr>
<tr>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
</tr>
<tr>
<td><img src="chico.png" /> <input type="checkbox" value="9"> <input type="text" value="0" size="2"></td>
<td><img src="grande.png" /><input type="checkbox" value="16"> <input type="text" value="0" size="2"></td>
<td><img src="chico.png" /> <input type="checkbox" value="10"> <input type="text" value="0" size="2" ></td>
<td><img src="grande.png" /> <input type="checkbox" value="18"> <input type="text" value="0" size="2" ></td>
</tr>
<tr>
<th colspan="2"><img src="pechugadepollo.png" / title="Riquísimo pastie de pollo deshebrado"></th><th colspan="2"><img src="polloychampiñones.png" / title="Pastie que convina el pollo deshebrado con champiñones trozeados, delicioso"></th></tr>
<tr>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
</tr>
<tr>
<td><img src="chico.png" /> <input type="checkbox" value="10"> <input type="text" value="0" size="2"></td>
<td><img src="grande.png" /><input type="checkbox" value="18"> <input type="text" value="0" size="2"></td>
<td><img src="chico.png" /> <input type="checkbox" value="10"> <input type="text" value="0" size="2" ></td>
<td><img src="grande.png" /> <input type="checkbox" value="18"> <input type="text" value="0" size="2" ></td>
</tr>
<tr>
<th colspan="2"><img src="carnederes.png" / title="Carne de res cocinada esplendidamente hacen de este un pastie digno de chuparse los dedos"></th><th colspan="2"><img src="dulces.png" / title="Nuestra selección de deliciosos y dulces pasties para toda ocasión"></th></tr>
<tr>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
</tr>
<tr>
<td><img src="chico.png" /> <input type="checkbox" value="10"> <input type="text" value="0" size="2"></td>
<td><img src="grande.png" /><input type="checkbox" value="18"> <input type="text" value="0" size="2"></td>
<td>Zarzamora & queso crema<input type="checkbox" value="10"> <input type="text" value="0" size="2" ></td>
<td>Nutella<input type="checkbox" value="18"> <input type="text" value="0" size="2" > </td>
</tr>
<tr>
<td align="right"></td>
<td align="right"></td>
<td align="right">¿Cuantos?</td>
<td align="right">¿Cuantos?</td>
</tr>
<tr>
<td></td>
<td></td>
<td>Piña & queso crema<input type="checkbox" value="10"> <input type="text" value="0" size="2" ></td>
<td>Dulce de leche<input type="checkbox" value="18"> <input type="text" value="0" size="2" > </td>
</tr>
<tr>
<th colspan="4"><input name="calcularprecio" type="submit" value="Calcular"> </th>
</tr>
<tr>
<th colspan="4"><font size="2"> Total: $<input type="total" id="total" readonly size=10>* pesos </font></th>
</tr>
<tr>
<th colspan="4">*Al precio se le han añadido $20 por tarifa de envío </th>
</tr>
</table>
<br /><br />
Información para envío del pedido
<table>
<tr>
<td><font size="2">Nombre: <input type="text" id="NombrePedido" size="30" ></font></td>
</tr>
<tr>
<td><font size="2">Dirección: <input type="text" id="Direccion" size="30" ></font></td>
</tr>
<tr>
<td><font size="2">Teléfono: <input type="text" id="telefono" size="30" >*</font></td>
</tr>
<tr>
<th colspan="2">*Confirmaremos su pedido vía teléfonica antes del envío</th>
</tr>
<tr>
<th colspan="2"><input name="Submit" type="submit" id="Submit" value="Enviar" /></th>
</tr>
</font>
</font>
</center>
</body>
</html>
¿Qué opinan?
