Solved

asp.net radiobuttonlist selectedindex in javascript

Posted on 2006-06-21
5
5,197 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
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
Nandakumar Sakthivel earned 250 total points
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now