focus() onLoad

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gordan

    focus() onLoad

    Hi!

    I have a very simple form and the idea is that when the page loads the focus
    is set on the first textfield so that the user can start typing immediately
    without pressing the tab key. so I did:

    body onLoad="documen t.form.txtfield .focus()"

    but id doesn't work, and no errors occurs. what gives?

    many thanks
    Gordan


  • The Plankmeister

    #2
    Re: focus() onLoad

    [color=blue]
    > body onLoad="documen t.form.txtfield .focus()"[/color]

    Perhaps the form doesn't have the name "form" or the text box isn't named
    "txtfield"? Only thing I can think of...

    Perhaps give the text box a unique ID attribute... something like
    id="text_focus " or whatever, then in the onload attribute do:

    body onload="documen t.getElementByI d('text_focus') .focus()"

    That way you're accessing the element directly, rahter than navigating the
    document tree.

    HTH.

    P.




    Comment

    • Wim Poorten

      #3
      Re: focus() onLoad

      The Plankmeister wrote:[color=blue][color=green]
      >> body onLoad="documen t.form.txtfield .focus()"[/color]
      >
      > Perhaps the form doesn't have the name "form" or the text box isn't
      > named "txtfield"? Only thing I can think of...[/color]

      Or there are 2 forms with the name "form", or there are 2 text fields
      with the name "txtfield".

      --

      Wim Poorten


      Comment

      • Gordan

        #4
        Re: focus() onLoad

        my spelling error :-(((

        Gordan
        "Wim Poorten" <invalid@nohost .com> wrote in message
        news:Lhibb.7272 $Ze1.745366915@ hestia.telenet-ops.be...[color=blue]
        > The Plankmeister wrote:[color=green][color=darkred]
        > >> body onLoad="documen t.form.txtfield .focus()"[/color]
        > >
        > > Perhaps the form doesn't have the name "form" or the text box isn't
        > > named "txtfield"? Only thing I can think of...[/color]
        >
        > Or there are 2 forms with the name "form", or there are 2 text fields
        > with the name "txtfield".
        >
        > --
        >
        > Wim Poorten
        >
        >[/color]


        Comment

        • nice.guy.nige

          #5
          Re: focus() onLoad

          While the city slept, Gordan <gordanMENE@tor kulMAKNI.hr> feverishly typed:
          [color=blue]
          > my spelling error :-((([/color]

          <g> Welcome to the fun and fulfilling world of debugging! ;-)

          I once (erm... 15 years ago... eek!) spent nearly 3 days going through
          several pages of COBOL code trying to find out why it wouldn't work...
          eventually found I'd missed a full stop (period) from the end of one line.
          Fixed that and it worked like a dream!

          Cheers,
          Nige

          --
          Nigel Moss.

          Email address is not valid. nigel@nigenetDO G.org.uk. Take the dog out!
          http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
          "How strange the change from major to minor..."


          Comment

          Working...