473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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
Jul 22 '08 #1
2 2025
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Randell D. | last post by:
Folks, I have a form (called FORM1) - In my INPUT submit tag, I have an onClick event that I have successfully tested/used to display the value of a TEXT box using the following function (called...
2
by: jason | last post by:
The following (likely far from imperfect code), reports a value of NaN in the j4 display. I suppose the problem is I am not really passing the "checked" value of the radio button via .value ......
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
1
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
2
by: Stoic | last post by:
I'm offering a selection of three items. One is $25, the second is $50, the third is $100. Along with selection one of the items I need to pass the quantity of the selection. Here is the code now....
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
4
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
3
by: romano2717 | last post by:
I have a test.php file that contains a set of radio buttons generated inside a loop. then I append the $i variable to the radio button name to have a unique set of radio buttons. the scenario...
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.