Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/07/2010, 12:46
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 3 meses
Puntos: 126
Respuesta: Problema con onblur y capa que se muestra

Hola

Pruba con esto. Necesitas un textfield con id txt y un div(capa) con el nombre contenedor

Código Javascript:
Ver original
  1. var SelUsuario = {
  2.  
  3. Evento: function (elemento,nomevento,funcion) {
  4.   if (elemento.attachEvent)
  5.   {
  6.       var f=function(){
  7.         funcion.call(elemento,window.event);
  8.     }
  9.     elemento.attachEvent('on'+nomevento,f);
  10.     return true;
  11.   }
  12.   else  
  13.     if (elemento.addEventListener)
  14.     {
  15.       elemento.addEventListener(nomevento,funcion,false);
  16.       return true;
  17.     }
  18.     else
  19.       return false;
  20. },
  21.  
  22.  
  23.  
  24. init: function(){
  25. var txtfield = document.getElementById("txt"); // el textfield
  26. var elem = document.getElementById("contenedor"); // la capa
  27.         SelUsuario.Evento(elem1, 'click', SelUsuario.Muestra);
  28.         SelUsuario.Evento(elem, 'mouseover', SelUsuario.Seleccionar);
  29.         SelUsuario.Evento(window, 'click', SelUsuario.Cerrar);
  30.     },
  31.  
  32.  
  33.  
  34. Muestra: function () {
  35. var obj = document.getElementById("contenedor")
  36.                 if (obj.style.display == "block"); obj.style.display= "none";      
  37. },
  38.  
  39.  
  40. Seleccionar: function () {
  41. var ref = document.getElementById(this.id).getElementsByTagName('DIV'); // la capa y DIV son los elementos que hay dentro de la capa
  42.  
  43. for (var i = 0; i < ref.length; i++) {
  44.  
  45. SelUsuario.Evento(ref[i], 'click', function() {
  46. SelUsuario.Pegar(this.id);
  47.  
  48. })  
  49. }
  50. },
  51.  
  52.  
  53.  
  54. Pegar: function (valor) {
  55. var obj = document.getElementById("contenedor")
  56.         document.getElementById("txt").value = valor;
  57.                 if (obj.style.display == "block"); obj.style.display= "none";      
  58. }
  59.  
  60. SelUsuario.Evento(window, 'load', SelUsuario.init);
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;" />