Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

asp.net radiobuttonlist selectedindex in javascript

Posted on 2006-06-21
5
Medium Priority
?
5,222 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 1000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 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