Solved

asp.net radiobuttonlist selectedindex in javascript

Posted on 2006-06-21
5
5,214 Views
Last Modified: 2012-06-27
Hello

I need to get the selectedindex of a asp.net 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>
</asp:radiobuttonlist>

The generated html becomes like this:
-------------------------------------------------------------------
<table id="rbl_menu_atgard" border="0">
<tr>
<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>
</tr>
<tr>
<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>
</tr>
<tr>
<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>
</td>
</tr>
</table>



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.

please

/Nick
0
Comment
Question by:nicas
[X]
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
5 Comments
 
LVL 6

Accepted Solution

by:
Nandakumar Sakthivel earned 250 total points
ID: 16950764
hi,
   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

Thanks,
Nanda
0
 
LVL 6

Expert Comment

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

Thanks,
Nanda
0

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 (https://www.adremsoft.com/). 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