Solved radiobuttonlist selectedindex in javascript

Posted on 2006-06-21
Last Modified: 2012-06-27

I need to get the selectedindex of a radiobuttonlist in a javascript, anyone know how to do this?

The radiobuttonlist is declared like this:
<asp:radiobuttonlist id="rbl_menu_atgard" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rbl_menu_atgard_OnChange">
<asp:ListItem Value="Scenario">Scenario</asp:ListItem>
<asp:ListItem Value="Prognos">Prognos</asp:ListItem>
<asp:ListItem Value="Regleringar">Rapportera regleringar</asp:ListItem>

The generated html becomes like this:
<table id="rbl_menu_atgard" border="0">
<td><input id="rbl_menu_atgard_0" type="radio" name="rbl_menu_atgard" value="Scenario" onclick="__doPostBack('rbl_menu_atgard_0','')" language="javascript" /><label for="rbl_menu_atgard_0">Scenario</label></td>
<td><input id="rbl_menu_atgard_1" type="radio" name="rbl_menu_atgard" value="Prognos" onclick="__doPostBack('rbl_menu_atgard_1','')" language="javascript" /><label for="rbl_menu_atgard_1">Prognos</label>
<td><input id="rbl_menu_atgard_2" type="radio" name="rbl_menu_atgard" value="Regleringar" checked="checked" onclick="__doPostBack('rbl_menu_atgard_2','')" language="javascript" /><label for="rbl_menu_atgard_2">Rapportera regleringar</label>

when i retrieve the radiobuttonlist in a javascript like this:
var menu = document.getElementById('rbl_menu_atgard');

i can't access the selectedindex and options array. I need help on how to solve this.


Question by:nicas
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

Nandakumar Sakthivel earned 250 total points
ID: 16950764
   you can use some thing like this

                      var val = 0;
                  for( i = 0; i < document.Form1.RadioButtonList1.length; i++ )
                        if(document.Form1.RadioButtonList1[i].checked == true )
                                    val = document.Form1.RadioButtonList1[i].value;
 RadioButtonList1 is name of the radio button group


Expert Comment

by:Nandakumar Sakthivel
ID: 17135940
              I think that what i had answered is relevant to the question and i think that my solution will solve the posted problem.


Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question