1

I put a couple of radio button in same group in following way:

<asp:RadioButton ID="ID11" Text="Text1" GroupName="G1" runat="server" />
<asp:RadioButton ID="ID12" Text="Text2" GroupName="G1" runat="server" />
<asp:RadioButton ID="ID13" Text="Text3" GroupName="G1" runat="server" />

IDs for each radio button generated dynamically. then I want to access those radio button in javascript. How to go through those radio buttons without use each ID?

1
  • @Xander indeed I had jQuery on my mind Commented Jan 26, 2012 at 15:17

2 Answers 2

1

you should be using a RadioButtonList

<asp:RadioButtonList id="rblOption" runat="server">
   <asp:ListItem Value="1" Text="Yes" />
   <asp:ListItem Value="0" Text="No" />
</asp:RadioButtonList>

and you can get the value using something like

    <script type="text/javascript">
        var rblOption= '<%= rbList.ClientID %>';
    </script>
Sign up to request clarification or add additional context in comments.

Comments

0

well, this is always going to generate to

<input type="radio" /> 

controls

imagine that they are a form with id 'form' you'd do something like:

var form = document.getElementById('form');
var controls = form.getElementsByTagName('input');
for(var control in controls){
   if(control.getAttribute('type') == 'radio'{
      //control will be a radiobutton
   }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.