Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/09/2009, 08:27
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

Podría ser algo como esto

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(m,c) {
  7. var unidad = 50;
  8. metros = (m != "") ? m : document.getElementById("metros").value ;
  9. cantidad = (c != "") ? c : 1;
  10. var total = parseInt((parseFloat(metros)*unidad)*cantidad);
  11. document.getElementById("total").value = total;
  12. }
  13. </script>
  14. </head>
  15. <body>
  16. <form>
  17. Metros Cuadrados <input type="text" id="metros" value="1" onkeyup="funcion(this.value,'');" /><br />
  18. Cantidad <input type="text" id="cantidad" value="1" onkeyup="funcion('',this.value);" /><br />
  19. Total <input type="text" id="total" value="" />
  20. </form>
  21. </body>
  22. </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;" />