Foros del Web » Programando para Internet » Javascript »

evento "focus"? o?

Estas en el tema de evento "focus"? o? en el foro de Javascript en Foros del Web. esta es mi tabla en html ok?, Código PHP: < table summary = "Meeting Results"  width = "75%"  height = "2%"  border = "0"  cellpadding = "0"  ...
  #1 (permalink)  
Antiguo 22/08/2008, 12:03
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Mensaje evento "focus"? o?

esta es mi tabla en html ok?,
Código PHP:
<table summary="Meeting Results" width="75%" height="2%" border="0" cellpadding="0" cellspacing="1" bordercolor="#B1C3D9" align="center">
<
tbody id="lineaPedido" class="fondo" align="center">        
  <
tr>
    <
td height="18" colspan="9" align="center" background="images/bg.JPG" bgcolor="#E0E0E0" scope="col"><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="2">Pedidos</font></td>
  </
tr>
 
 <
tr>
    <
th height="18" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">#</span></th>
    
<th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7" style="text-align:center">PRODUCTO</span></th>
    <
th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">UDM</span></th>
    <
th align="center" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">DESCRIPCION</span></th>
    <
th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">EXISTENCIA</span></th>
    <
th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">ZONA</span></th>
    <
th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">PRECIO</span></th>
    <
th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">CANTIDAD</span></th>
    <
th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">IMPORTE</span></th>
 </
tr>  
 <
tr>
<!--     
En ajax.js de la funcion añadir existe una lista que debe contener todos los campos de esta tabla 
 
-->    <th width="20" height="14" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" id="lineaPedido2"><span class="Estilo4 Estilo5 Estilo6">1</span></th>
    <
th width="50" height="14" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col"><input type="text" id="Item" class="input" style="width:57px; height:14px; border-width:0px"  onblur="RecuperaDescripcion(this.id,this.value,'Itemno','Uomcode Description','datos_articulo')" maxlength="7"/></th>
    <
th background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" width="70"><div id="datos_udm" style="font-size:14px"></div></th>
    <
td  width="340" align="center" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col"><div id="datos_articulo" class="Estilo3" style="font-size:10px; font-weight: bold"></div></td>
    <
th background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" width="100"><div id="datos_ext1" style="font-size:14px"></div></th>
    <
th background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" width="60"><div id="datos_zon1" style="font-size:14px"></div></th>
    <
td width="70" height="14" valign="middle" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col">
      <
div align="left"><div class="Estilo3" style="font-size:12px">$
          <
input type="text" id="precio" class="input" style="width:50px; height:14px; text-align:center;border-width:0px" maxlength="15"/>
      </
div></div></td>
    <
th width="50" height="14" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col"><input type="text" id="cantidad" class="input"  style="width:50px; height:14px; text-align:center;border-width:0px" onblur="calculaPrecio(document.getElementById('precio').value,this.value);anadir()" maxlength="7"/></th>
    <
th background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" width="57"><span id="importe" class="Estilo3" style="font-size:11px;">&nbsp;</span></th>
  </
tr>
</
tbody>
</
table
quiero aplicar un evento, que al terminar de capturar "cantidad" me regrese al primer text_input "Item" se podra? gracias...
  #2 (permalink)  
Antiguo 22/08/2008, 12:14
Avatar de Fernand0  
Fecha de Ingreso: septiembre-2005
Ubicación: Buenos Aires
Mensajes: 610
Antigüedad: 18 años, 7 meses
Puntos: 19
Respuesta: evento "focus"? o?

Código PHP:
document.getElementById('Item').focus() 
De paso ponele
Código PHP:
document.getElementById('Item').value='' 
asi queda re piola =P
  #3 (permalink)  
Antiguo 22/08/2008, 12:28
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

ahhh... lo intente antes y nada, nose donde colocarlo. me tiras un cable?
  #4 (permalink)  
Antiguo 22/08/2008, 12:31
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: evento "focus"? o?

Cita:
Iniciado por art33 Ver Mensaje
ahhh... lo intente antes y nada, nose donde colocarlo. me tiras un cable?
Pues, donde colocarlo depende de cuándo quieres que el foco pase al otro input, ¿sería cuando se llene el otro campo?. Entonces podrías usar el evento onkeypress y ver si el campo ya está lleno, si así es pasar el foco al otro input.
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #5 (permalink)  
Antiguo 22/08/2008, 12:34
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

es k en ese input ya tengo un
Código PHP:
onblur="calculaPrecio(document.getElementById('precio').value,this.value);anadir()" 
nose donde colocar este evento... soy novatin jeje "Jelp"
  #6 (permalink)  
Antiguo 22/08/2008, 12:40
Avatar de Fernand0  
Fecha de Ingreso: septiembre-2005
Ubicación: Buenos Aires
Mensajes: 610
Antigüedad: 18 años, 7 meses
Puntos: 19
Respuesta: evento "focus"? o?

Código PHP:
onblur="calculaPrecio(document.getElementById('precio').value,this.value); anadir(); document.getElementById('Item').focus(); document.getElementById('Item').value='';" 
lo podes hacer mas complejo.. como dice David el Grande
  #7 (permalink)  
Antiguo 22/08/2008, 13:11
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

pues me van a dar asotes... jeje, pero no anda, ya habia intentado algo parecido, pero nop, si me deja el input en blanco pero no me deja segui capturando es decir nose keda la "|" intermitente... k sera?... en teoria debe funcionar tal y como me pusiste el codigo no?, pero no anda....
  #8 (permalink)  
Antiguo 22/08/2008, 13:16
Avatar de Fernand0  
Fecha de Ingreso: septiembre-2005
Ubicación: Buenos Aires
Mensajes: 610
Antigüedad: 18 años, 7 meses
Puntos: 19
Respuesta: evento "focus"? o?

probaste escribiendo? a mi nunca me dejo la "|".. pero empezas a escribir y ya esta
  #9 (permalink)  
Antiguo 22/08/2008, 13:22
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

aja, eso pense, Fernand0, pero le escribi y nada... en firefox, no hace nada pero en ie se va a la barra de direcciones...
  #10 (permalink)  
Antiguo 22/08/2008, 13:25
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Pregunta Respuesta: evento "focus"? o?

¿Podrías poner un enlace a tu página?. Así podremos ver cuál es exactamente el error.
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #11 (permalink)  
Antiguo 22/08/2008, 13:32
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

:P David el Grande puse el codigo de mi tabla arribita.. jeje, estodo... nose que pasa, yo no le veo error.. que sera?
  #12 (permalink)  
Antiguo 22/08/2008, 13:37
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Exclamación Respuesta: evento "focus"? o?

Pero en el código que pusiste arriba solo hay una fila y no entendí muy bien lo que quieres hacer con ella .
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #13 (permalink)  
Antiguo 22/08/2008, 13:40
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

no comprendo... solo kiero hacer el "focus", k mas necesitas? y lo pongo.... X|
  #14 (permalink)  
Antiguo 22/08/2008, 13:52
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: evento "focus"? o?

Creo que ya entendí, pero bueno, lo cierto es que en el evento onblur ya hice muchas pruebas y no conseguí que vuelva el foco al Item, tal vez podemos intentar capturar la tecla Tab con el onkeypress y anular el evento pero a la vez pasar el foco al Item.
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #15 (permalink)  
Antiguo 22/08/2008, 13:56
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

aja... seria bueno, se podra?, ya me lie, y no puedo... jeje... un cable?
  #16 (permalink)  
Antiguo 22/08/2008, 14:07
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Exclamación Respuesta: evento "focus"? o?

Haciendo una búsqueda por el foro encontré la solución que te mencioné (aunque con onkeydown y no con onkeypress como en un principio pensé):
http://www.forosdelweb.com/f13/detec...ulario-446425/
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #17 (permalink)  
Antiguo 22/08/2008, 14:13
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

pues ni eso, nose k hago mal... nada me funciona...
  #18 (permalink)  
Antiguo 22/08/2008, 14:15
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Pregunta Respuesta: evento "focus"? o?

Yo lo probé y funciona perfectamente, ¿podrías poner el código tal y como lo tienes ahora?.
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #19 (permalink)  
Antiguo 22/08/2008, 14:20
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

aki esta
Código PHP:
<script>
function 
tab_btn(event)
{
    var 
event.keyCode event.keyCode event.which event.which event.charCode;
    if (
== 9
    {
        
x_busca.element().focus(); 
        return 
false;
    }
    return 
true;
}    
</script>
<table summary="Meeting Results" width="75%" height="2%" border="0" cellpadding="0" cellspacing="1" bordercolor="#B1C3D9" align="center">
<tbody id="lineaPedido" class="fondo" align="center">        
  <tr>
    <td height="18" colspan="9" align="center" background="images/bg.JPG" bgcolor="#E0E0E0" scope="col"><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="2">Pedidos</font></td>
  </tr>
 
 <tr>
    <th height="18" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">#</span></th>
    <th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7" style="text-align:center">PRODUCTO</span></th>
    <th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">UDM</span></th>
    <th align="center" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">DESCRIPCION</span></th>
    <th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">EXISTENCIA</span></th>
    <th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">ZONA</span></th>
    <th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">PRECIO</span></th>
    <th height="14" background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">CANTIDAD</span></th>
    <th background="images/bginp.jpg" bgcolor="#E0E0E0" scope="col"><span class="Estilo7">IMPORTE</span></th>
 </tr>  
 <tr>
<!--     En ajax.js de la funcion añadir existe una lista que debe contener todos los campos de esta tabla 
 -->    <th width="20" height="14" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" id="lineaPedido2"><span class="Estilo4 Estilo5 Estilo6">1</span></th>
    <th width="50" height="14" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col"><input type="text" id="Item" class="input" style="width:57px; height:14px; border-width:0px"  onblur="RecuperaDescripcion(this.id,this.value,'Itemno','Uomcode Description','datos_articulo')" maxlength="7"/></th>
    <th background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" width="70"><div id="datos_udm" style="font-size:14px"></div></th>
    <td  width="340" align="center" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col"><div id="datos_articulo" class="Estilo3" style="font-size:10px; font-weight: bold"></div></td>
    <th background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" width="100"><div id="datos_ext1" style="font-size:14px"></div></th>
    <th background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" width="60"><div id="datos_zon1" style="font-size:14px"></div></th>
    <td width="70" height="14" valign="middle" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col">
      <div align="left"><div class="Estilo3" style="font-size:12px">$
          <input type="text" id="precio" class="input" style="width:50px; height:14px; text-align:center;border-width:0px" maxlength="15"/>
      </div></div></td>
    <th width="50" height="14" background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col"><input type="text" id="cantidad" class="input"  style="width:50px; height:14px; text-align:center;border-width:0px"  onblur="calculaPrecio(document.getElementById('precio').value,this.value); anadir(); document.getElementById('Item').focus(); document.getElementById('Item').value='';" onKeyDown="return tab_btn(event);"/></th>
    <th background="images/bodyarea-bg.gif" bgcolor="#E0E0E0" scope="col" width="57"><span id="importe" class="Estilo3" style="font-size:11px;">&nbsp;</span></th>
  </tr>
</tbody>
</table> 
esta bien no?... aver k pasa
  #20 (permalink)  
Antiguo 22/08/2008, 14:24
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Exclamación Respuesta: evento "focus"? o?

El caso es que no cambiaste el elemento al que quieres enviar el foco, cambia esto:
Código PHP:
x_busca.element().focus(); 
Por:
Código PHP:
document.getElementById('Item').focus(); 
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #21 (permalink)  
Antiguo 22/08/2008, 14:44
 
Fecha de Ingreso: agosto-2008
Mensajes: 272
Antigüedad: 15 años, 9 meses
Puntos: 4
Respuesta: evento "focus"? o?

kedo bonito ahora si mi....
____________
| |
‾‾‾‾‾‾‾‾‾‾‾‾
gracias a los 2....... chao..
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:23.