Ver Mensaje Individual
  #9 (permalink)  
Antiguo 10/05/2014, 10:14
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 1 mes
Puntos: 292
Respuesta: Problema con variables globales!

Que pena si me meto mal....... tambien soy nuevo en JS... probé la sugerencia de @Alexis88 de usar el evento Onload() y me fue perfecto:

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script language="JavaScript">
  4.    
  5.     function al_cargar()
  6.     {
  7.     var inputA = document.getElementById("inputA");
  8.     var inputB = document.getElementById("inputB");
  9.     }
  10.    
  11.     function x()
  12.     {      
  13.         inputA.style.display = "none";
  14.         inputB.style.color = "yellow";
  15.         alert('Entre');
  16.     }
  17. </script>
  18. </head>
  19. <body onload="al_cargar();">
  20.     <a href="#n" onclick="x()">CLIC 1</a>
  21.     <a href="#n" onclick="x()">CLIC 2</a>
  22.  
  23.     <input id="inputA" value="HOLA 1" />
  24.     <input id="inputB" value="HOLA 2" /></p>
  25. </body>
  26. </html>
__________________
Salu2!