Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    May 2004
    Posts
    388
    Thanks
    73
    Thanked 0 Times in 0 Posts

    form field focus

    Is it possible to place focus on a text field without using body onload??

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,467
    Thanks
    3
    Thanked 495 Times in 482 Posts
    onload=document.getElementById('mytextfieldid')focus();"

  • #3
    Regular Coder
    Join Date
    May 2004
    Posts
    388
    Thanks
    73
    Thanked 0 Times in 0 Posts
    How about without using <body onload>? Thanks
    Tracy

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    vwphillips suggestion can be placed in a javascript block, not in the body tag.

    Just out of curiousity, why don't you want it in the <body onload>?

  • #5
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,467
    Thanks
    3
    Thanked 495 Times in 482 Posts
    you can also use window onload

    or use th call a function as previous post if the block is placed after the textbox element

    plus typo
    should be
    onload=document.getElementById('mytextfieldid').focus();
    Last edited by vwphillips; 01-18-2006 at 10:22 PM.

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Typo too?
    Quote Originally Posted by vwphillips
    plus typo
    should be
    onload=document.getElementById('mytextfieldid').focus();
    Should it be
    Code:
    onload=function(){document.getElementById('mytextfieldid').focus()};
    ?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •