Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/06/2010, 14:38
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: Como obtengo el nombre del input text dinamico ?????????'

Hola

A ver si es esto lo que buscas

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function calcular(cual) {
  5. valores = new Array();
  6. for (i = 0, campos = document.frm[cual].length; i < campos; i++) {
  7. valores[valores.length] = document.frm[cual][i].value;
  8. }
  9.  
  10. var promedio = 0;
  11. for (i = 0; i < valores.length; i++) {
  12. promedio += (valores[i]/3);
  13. }
  14. document.frm['prom_'+cual].value = promedio;
  15. }
  16. </script>
  17. </head>
  18. <body>
  19. <form name="frm">
  20. <input type="text" value="" name="nota_1" onkeyup="calcular(this.name)" ><br />
  21. <input type="text" value="" name="nota_1" onkeyup="calcular(this.name)" ><br />
  22. <input type="text" value="" name="nota_1" onkeyup="calcular(this.name)" ><br />
  23. <input type="text" value="" name="prom_nota_1">
  24.  
  25. <br /><br />
  26.  
  27. <input type="text" value="" name="nota_2" onkeyup="calcular(this.name)" ><br />
  28. <input type="text" value="" name="nota_2" onkeyup="calcular(this.name)" ><br />
  29. <input type="text" value="" name="nota_2" onkeyup="calcular(this.name)" ><br />
  30. <input type="text" value="" name="prom_nota_2">
  31. </form>
  32. </body>
  33. </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;" />