By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,798 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

How to find the value of a radio button

P: n/a
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
Jul 22 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Jul 21, 5:41 pm, donpro <donpro-2...@rogers.comwrote:
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

Jul 22 '08 #2

P: n/a
On Jul 22, 10:41*am, donpro <donpro-2...@rogers.comwrote:
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
Jul 22 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.