How to find the value of a radio button

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

    How to find the value of a radio button

    Hi,

    Does anyone know how to use DOM to find the value of a selected radio
    both (or if none were selected)?

    My web page displays a set of radio buttons - the number is dynamic so
    could be one or 100; I do this within a loop.

    At the moment, I'm giving each one the same name and ID - not sure if
    giving the same ID is correct or not. By default, no radio buttons
    are selected when the page loads

    When the user clicks on a a specific button on the page, I need to
    check if a radio button was selected or not. I trap the 'click' event
    but my code to get the radio button value has failed.

    Thanks,
    Don
  • Peter Michaux

    #2
    Re: How to find the value of a radio button

    On Jul 21, 5:41 pm, donpro <donpro-2...@rogers.com wrote:
    Hi,
    >
    Does anyone know how to use DOM to find the value of a selected radio
    both (or if none were selected)?
    >
    My web page displays a set of radio buttons - the number is dynamic so
    could be one or 100; I do this within a loop.
    >
    At the moment, I'm giving each one the same name and ID - not sure if
    giving the same ID is correct or not. By default, no radio buttons
    are selected when the page loads
    >
    When the user clicks on a a specific button on the page, I need to
    check if a radio button was selected or not. I trap the 'click' event
    but my code to get the radio button value has failed.
    A good place to start is the group FAQ



    The longer FAQ note linked in the answer to the above FAQ is valuable.

    Peter

    Comment

    • RobG

      #3
      Re: How to find the value of a radio button

      On Jul 22, 10:41 am, donpro <donpro-2...@rogers.com wrote:
      Hi,
      >
      Does anyone know how to use DOM to find the value of a selected radio
      both (or if none were selected)?
      Yes, see Peter's reply.

      My web page displays a set of radio buttons - the number is dynamic so
      could be one or 100; I do this within a loop.
      >
      At the moment, I'm giving each one the same name and ID - not sure if
      giving the same ID is correct or not.
      It is not correct, the value of each ID attribute must be unique in
      the page. Giving buttons the same name is OK, it forms them into
      groups. Onlly give them IDs if they really need them.


      --
      Rob

      Comment

      Working...