Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Finding the value of a group of ASP.net radio buttons using JavaScript

Avatar of najh
najhFlag for United Kingdom of Great Britain and Northern Ireland asked on
6 Comments1 Solution752 ViewsLast Modified:
I have a huge set of radio buttons - arranged in several groups.

I need to be able to check the value of these groups.

So here's a bit of example code:
<div class="possibles">
              <asp:RadioButtonList ID="RadioButtonList1" runat="server"   >
                <asp:ListItem Value="1">a</asp:ListItem>
                <asp:ListItem Value="2">b</asp:ListItem>
                <asp:ListItem Value="3">c</asp:ListItem>
                <asp:ListItem Value="4">d</asp:ListItem>
                <asp:ListItem Value="5">e</asp:ListItem>

I've got some JavaScript which does a bit of checking to see if any of the items are selected (I don't actually care which one is selected, I just need to know that one is)

Here's how the JavaScript looks:

function findRadioButtonValue(checkBoxGroupToCheck){
        for (var i = 0; i < document.getElementById(checkBoxGroupToCheck).length; i++){
                  if (radioButtons[i].checked == true){
                        return radioButtons[i].value;

however it doesn't seem to recognise the group of radio buttons - it seems to recognise the id provided (RadioButtonList1) in this case as a table element. (which it indeed is when i look in the html source code of the page from the browser).

So how do i reference the group of radio buttons so that i can get them checked?
By the way i use C#, so any vb excerpts won't mean much to me.
Avatar of najh
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers