onload = generically focus on first control

Discussion in 'Javascript' started by Fred, Aug 23, 2008.

  1. Fred

    Fred Guest

    Hi. Can I make the first control (textfield or text area) get focus via
    onload, without referring to the object's name of id? Thanks.
    Fred, Aug 23, 2008
    #1
    1. Advertising

  2. Fred

    Kiran Makam Guest

    You can do this using the form object's elements collection:

    window.onload = function(){
    document.yourFormName.elements[0].focus();
    }


    On Aug 23, 8:21 pm, Fred <> wrote:
    > Hi. Can I make the first control (textfield or text area) get focus via
    > onload, without referring to the object's name of id? Thanks.
    Kiran Makam, Aug 24, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SN
    Replies:
    4
    Views:
    380
    Tony Dahlman
    Nov 13, 2003
  2. Jason
    Replies:
    4
    Views:
    1,594
    Jason
    May 7, 2007
  3. reneecccwest
    Replies:
    1
    Views:
    89
    McKirahan
    Feb 24, 2004
  4. Zvonko
    Replies:
    1
    Views:
    107
  5. Roger
    Replies:
    3
    Views:
    310
Loading...

Share This Page