Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/09/2009, 13:51
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 1 mes
Puntos: 126
Respuesta: Cálculo sencillo

Hola

A efectos prácticos es lo mismo. Te he montado este otro

Código javascript:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta name="http-equiv" content="Content-type: text/html; charset=UTF-8"/>
  5. <script type="text/javascript">
  6. function funcion(sel1,sel2) {
  7. var unidad = 50;
  8. if (sel1 == "") {metros = document.pedidos.metros.options[document.pedidos.metros.selectedIndex].value;} else { metros = sel1;}
  9. if (sel2 == "") {cantidad = document.pedidos.cantidad.options[document.pedidos.cantidad.selectedIndex].value;} else { cantidad = sel2;}
  10. var total = parseInt((parseFloat(metros)*unidad)*cantidad);
  11. document.getElementById("total").value = total;
  12. }
  13. </script>
  14. </head>
  15. <body>
  16. <form name="pedidos">
  17. Metros Cuadrados <select name="metros" id="metros" onchange="funcion(this.options[this.selectedIndex].value,'');">
  18. <option value="0">METROS</option>
  19. <option value="1">100x100</option>
  20. <option value="1.5">150x150</option>
  21. <option value="2">200x200</option>
  22. <option value="2.5">250x250</option>
  23. <option value="3">300x300</option>
  24. </select>
  25. <br />
  26.  
  27. Cantidad <select name="cantidad" id="cantidad" onchange="funcion('',this.options[this.selectedIndex].value);">
  28. <option value="0">CANTIDAD</option>
  29. <option value="1">1</option>
  30. <option value="2">2</option>
  31. <option value="3">3</option>
  32. <option value="4">4</option>
  33. <option value="5">5</option>
  34. </select>
  35.  
  36. <br />
  37. Total <input type="text" id="total" value="0" />
  38. </form>
  39. </body>
  40. </html>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />