JavaScript - No me aparece el calculo correctamente

 
Vista:
sin imagen de perfil
Val: 13
Ha disminuido su posición en 8 puestos en JavaScript (en relación al último mes)
Gráfica de JavaScript

No me aparece el calculo correctamente

Publicado por Unexes (39 intervenciones) el 14/04/2017 00:29:56
Hola.
Vereis tengo un problema no consigo que el imput "Coste_Bruto" me muestre el calculo correctamente.
De entrada me debería mostrar un valor de "300" ya que el select "impresión" esta seleccionado de entrada en 2 caras y me muestra "0"
Cuando cambio el select y selecciono 1 Cara debería mostrarme "150" el valor de la impresión es de 10 x 15 = 150 y me muestra 300 y cuando selecciono 2 Caras el valor de la impresión es de 20 x 15 = 300 y me muestra 150.
¿Que es lo que estoy haciendo mal?
Os agradecería vuestra ayuda, este es el código que tengo, simplificado.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!doctype html>
<html>
<head>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8">
<script type="text/javascript">
function calcular() {
var impresion =  document.getElementById("costeimpresion").value;
var costebruto = parseFloat(document.getElementById("Coste_Bruto").value = impresion*15);
   if (document.getElementById('impresion').value == 1)
        {document.getElementById('labelimpresion').value ='Impresas a 1 Cara';
		 document.getElementById('costeimpresion').value = 10;}
 
            else if(document.getElementById('impresion').value == 2)
                {document.getElementById('labelimpresion').value ='Impresas a 2 Caras';
				 document.getElementById('costeimpresion').value = 20;}
}
</script>
</head>
<body onload="calcular();">
<form method="POST" action="" name="form">
<div id="Impresion">
<select name="impresion" id="impresion" onchange="calcular();">
<option value="1">1 Cara</option>
<option value="2" selected>2 Caras</option>
</select>
</div>
<input style="border:none"  type="text" id="labelimpresion"/>
<input style="border:none"  type="text" id="costeimpresion"/>
<input style="border:none"  type="text" id="Coste_Bruto" value=""/>
</form>
</div>
</body>
</html>

GRACIAS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder