Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/09/2016, 22:20
borisvargas
 
Fecha de Ingreso: enero-2016
Ubicación: Chie
Mensajes: 2
Antigüedad: 8 años, 3 meses
Puntos: 0
Pregunta cotización html

Hola, quisiera saber si alguien pudiera ayudarme con esto. Es un código que permite calcular el precio de un producto y se puede agregar varios a la caja y conocer el precio total.
La ayuda que solicito por favor, es conocer cómo se puede agregar la opción de que la cantidad del o los productos elegidos pueda ser más de uno. Ej: producto 1, 5 unidades, producto 2, 1 unidad, producto 3, 15 unidades.
Gracias.

Este es el código:

<html>


<!-- Mirrored from www.htmlweb.net/manual/formularios/jscript/calculos/ejemplo_2.html by HTTrack Website Copier/3.x [XR&CO'2004], Wed, 29 Sep 2004 15:02:12 GMT -->
<head>
<title>formularios - c&aacute;lculos matem&aacute;ticos - ejemplo 2</title>
<style>


H1 {color:yellow; font-size:30pt; border-bottom: solid yellow 1;font-family:arial }

INPUT {width:50; background-color: green; font-weight: bold; color: white}

SELECT {width: 150; background-color: lightyellow; color: darkgreen}

</style>
<script>
var suma;
suma = 0;
function f1(){
if(select1.selectedIndex != -1){
i = select1.selectedIndex;
n = select2.options.length;
select2.options[n] = document.createElement("OPTION");
select2.options[n].text = select1.options[i].text;
select2.options[n].value = select1.options[i].value;
suma += parseInt(select1.options[i].value);
select1.options[i] = null;
total.value = suma + "pts";
}
}

function f2(){
if(select2.selectedIndex != -1){
i = select2.selectedIndex;
n = select1.options.length;
select1.options[n] = document.createElement("OPTION");
select1.options[n].text = select1.options[i].text;
select1.options[n].value = select2.options[i].value;
suma -= parseInt(select2.options[i].value);
select2.options[i] = null;
total.value = suma + "pts";
}
}
</script>
</head>

<body bgcolor="#268E87">

<center><h1>La lista de la compra</h1></center>
<div align="center"><center>

<table border="0">
<tr>
<td width="33%" align="center"><select id="select1" size="6">
<option value="500">Manzanas 500pts</option>
<option value="300">Peras 300pts</option>
<option value="400">Platanos 400pts</option>
<option value="200">Fresas 200pts</option>
<option value="100">Limones 100pts</option>
<option value="300">Naranjas 300pts</option>
<option value="100">Pomelos 100pts</option>
<option value="350">Mangos 350pts</option>
</select></td>
<td width="33%" align="center"><input type="button" value="--&gt;" name="Derecha"
onclick="f1()"><p><input type="button" value="&lt;--" name="Izquierda" onclick="f2()"></td>
<td width="34%" align="center"><select id="select2" size="6">
</select></td>
</tr>
<tr>
<td width="33%" align="center"></td>
<td width="33%" align="center"><p align="right"
style="font-family: arial; font-size: 12pt; font-weight: bold; color: yellow;">Total</td>
<td width="34%" align="center"><p align="left"><input id="total"
style="background-color:lightgreen;width:150;color:red;text-align:center;font-size:12pt"
type="text" name="T1" size="20"></td>
</tr>
</table>
</center></div>

<p>&nbsp;</p>
</body>

<!-- Mirrored from www.htmlweb.net/manual/formularios/jscript/calculos/ejemplo_2.html by HTTrack Website Copier/3.x [XR&CO'2004], Wed, 29 Sep 2004 15:02:12 GMT -->
</html>