Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Testing for a text box on a page
Message
De
02/08/2001 10:38:12
 
 
À
02/08/2001 08:27:34
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
Information générale
Forum:
Internet
Catégorie:
Javascript
Divers
Thread ID:
00538753
Message ID:
00538815
Vues:
12
This message has been marked as the solution to the initial question of the thread.
>How can I test if a text box exists on a web page?
>
>I am trying to set focus to a text box when my page loads. The ONLOAD calls this line.
>
> document.MYFORMNAME['txt_part'].focus();
>
>This works great!
>
>However, I build my form on the fly and sometimes my text box is not there. If it is not there, then the above line displays an error message.
>
>Is there a way to test if the text box exists before trying to set focus?
>
>Thanks,
>
>Jerryt

This is on the client side right?

Try this:
if (document.MYFORMNAME['txt_part']){
  document.MYFORMNAME['txt_part'].focus();
}
I may have missed the exact syntax (I'm just getting started on JS) but you get the idea.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform