Ver Mensaje Individual
  #5 (permalink)  
Antiguo 19/01/2013, 16:31
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: Desactivar dos campos de texto al escribir en otro campo

Yo no digo que no sea posible

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>texto disabled</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6.  
  7. <script type="text/javascript">
  8. //<![CDATA[
  9. function m_o(cual) {
  10. var capas = new Array("campo1", "campo2", "campo3");
  11. var cadenaL = document.getElementById(cual).value.length;
  12. var i;
  13.  
  14. if(cadenaL != 0){
  15. for(i in capas){
  16.         if(capas[i] != cual){
  17.         document.getElementById(capas[i]).disabled = true;
  18.         }
  19. }
  20. }else{
  21. for(i in capas){
  22. document.getElementById(capas[i]).disabled = false;
  23. }
  24.  
  25.  
  26. }
  27. }
  28. //]]>
  29. </head>
  30. <form action="#" method="post">
  31. <input type="text" id="campo1" value="campo1" onkeyup="m_o('campo1');" /><br />
  32. <input type="text" id="campo2" value="campo2" onkeyup="m_o('campo2');"/><br />
  33. <input type="text" id="campo3" value="campo3" onkeyup="m_o('campo3');"/><br />
  34. </form>
  35. </body>
  36. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.