Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/09/2013, 14:59
yerhods
 
Fecha de Ingreso: septiembre-2013
Mensajes: 2
Antigüedad: 10 años, 7 meses
Puntos: 0
Respuesta: Añadir datos a dos arrays, y consultarlo

Bueno si he entendido bien quieres guardar los valores en un array y luego mostarlos en función a lo que pongas.Si es así este es el código

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2. var miArray= new Array();
  3. function añadir(valor1,valor2)
  4. {
  5.     miArray[miArray.length] = valor1;
  6.     miArray[miArray.length] = valor2;
  7.    
  8. }
  9. function mostrar(valorPorTeclado)
  10. {
  11.    
  12.     alert(miArray[valorPorTeclado]);
  13.  
  14. }
  15. </head>
  16. <form name="formulario" >
  17. <tr><td>Producto:</td><td> <input type="text" name="produc" id="producto" value=""/></td></tr>
  18. <tr><td>Precio: </td><td> <input type="text" name="prec" id="precio" /><input type="button" value="Añadir" onclick="añadir(document.formulario.produc.value,document.formulario.prec.value)" /></td></tr>
  19. </form>
  20. <form name="fomulario2" ><br>
  21. <input size=10 name="area" value=""/>
  22. <input type="button" value="Buscar" name="busqueda" onclick="mostrar(document.fomulario2.area.value);"/>
  23. </form>
  24. </body>
  25. </html>