Setting focus on radio button

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

    Setting focus on radio button

    Hi All:

    I would like to know how to set the focus on a radio button (if it is
    possible)

    I tried button[0].focus() but with no luck

    The reason that I need to do this is to validate a form. If the user does
    not select a radio button I would like my validation code to set the focus
    at the first radio button within the pair that was not selected that way
    he/she does not have to look for it.

    Thanks in advance
    Terry


  • kaeli

    #2
    Re: Setting focus on radio button

    In article <nyEcb.120617$D Z.21199@news04. bloor.is.net.ca ble.rogers.com> ,
    tgmurray@rogers .com enlightened us with...[color=blue]
    > Hi All:
    >
    > I would like to know how to set the focus on a radio button (if it is
    > possible)
    >
    > I tried button[0].focus() but with no luck
    >[/color]

    document.formna me.elements["radioname"][index].focus();

    Radios are an array because they all have the same name.
    The index goes from 0-(length -1).

    -------------------------------------------------
    ~kaeli~
    All I ask for is the chance to prove that money
    cannot make me happy.


    -------------------------------------------------

    Comment

    • Terry Murray

      #3
      Re: Setting focus on radio button

      Thanks kaeli it seemed to work. Although the focus was only brought close
      to the button. Actually the button did not really receive the focus.
      Instead what happened was that the form was scrolled to an area that
      contained the radio button.

      Terry

      "kaeli" <infinite.possi bilities@NOSPAM att.net> wrote in message
      news:MPG.19dce3 4e42f6ce0098988 3@nntp.lucent.c om...[color=blue]
      > In article <nyEcb.120617$D Z.21199@news04. bloor.is.net.ca ble.rogers.com> ,
      > tgmurray@rogers .com enlightened us with...[color=green]
      > > Hi All:
      > >
      > > I would like to know how to set the focus on a radio button (if it is
      > > possible)
      > >
      > > I tried button[0].focus() but with no luck
      > >[/color]
      >
      > document.formna me.elements["radioname"][index].focus();
      >
      > Radios are an array because they all have the same name.
      > The index goes from 0-(length -1).
      >
      > -------------------------------------------------
      > ~kaeli~
      > All I ask for is the chance to prove that money
      > cannot make me happy.
      > http://www.ipwebdesign.net/wildAtHeart
      > http://www.ipwebdesign.net/kaelisSpace
      > -------------------------------------------------[/color]


      Comment

      • kaeli

        #4
        Re: Setting focus on radio button

        In article <vhGcb.122274$D Z.59829@news04. bloor.is.net.ca ble.rogers.com> ,
        tgmurray@rogers .com enlightened us with...[color=blue]
        > Thanks kaeli it seemed to work. Although the focus was only brought close
        > to the button. Actually the button did not really receive the focus.
        > Instead what happened was that the form was scrolled to an area that
        > contained the radio button.
        >[/color]

        That is the expected behavior from what I understand. Otherwise, it
        would be a click and would select it. Instead, it focuses on the radio
        group (object) containing that element.

        If someone knows otherwise, please correct me.

        -------------------------------------------------
        ~kaeli~
        All I ask for is the chance to prove that money
        cannot make me happy.


        -------------------------------------------------

        Comment

        Working...