Ver Mensaje Individual
  #21 (permalink)  
Antiguo 07/11/2016, 07:58
mpozo
 
Fecha de Ingreso: noviembre-2015
Mensajes: 231
Antigüedad: 8 años, 5 meses
Puntos: 86
Respuesta: Meter en un input un resultado javascript

Es mas sencillo. A groso modo
Código Javascript:
Ver original
  1. <!DOCTYPE html>
  2. <html dir="ltr" lang="es-es">
  3.     <head>
  4.         <title></title>
  5.         <meta charset="utf-8">
  6.         <style>
  7.        
  8.         </style>
  9.         <script>
  10.         function calcular(cual) {
  11.             var promedio = 0;
  12.             for (var i = 0; i < document.frm[cual].length; i++) {
  13.                 promedio += (document.frm[cual][i].value/3);
  14.             }
  15.             document.frm['prom_'+cual].value = (promedio).toFixed(2);
  16.         }
  17.  
  18.         </script>
  19.     </head>
  20.     <body>
  21.         <form name="frm">
  22.             <b>Notas 1</b><br />
  23.             Lenguaje: <input type="text" value="" name="nota_1" onkeyup="calcular(this.name)"><br>
  24.             Inglés: <input type="text" value="" name="nota_1" onkeyup="calcular(this.name)"><br>
  25.             Matemáticas: <input type="text" value="" name="nota_1" onkeyup="calcular(this.name)"><br>
  26.             Promedio: <input type="text" value="" name="prom_nota_1">
  27.  
  28.             <br /><br />
  29.             <b>Notas 2</b><br />
  30.             Lenguaje: <input type="text" value="" name="nota_2" onkeyup="calcular(this.name)"><br>
  31.             Inglés: <input type="text" value="" name="nota_2" onkeyup="calcular(this.name)"><br>
  32.             Matemáticas: <input type="text" value="" name="nota_2" onkeyup="calcular(this.name)"><br>
  33.             Promedio: <input type="text" value="" name="prom_nota_2">
  34.         </form>
  35.  
  36.     </body>
  37. </html>