How to find the value of a radio button

D

donpro

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
 
P

Peter Michaux

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

http://jibbering.com/faq/#FAQ4_13

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

Peter
 
R

RobG

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top