Solved

set radiobuttonlist with javascript

Posted on 2014-01-17
2
350 Views
Last Modified: 2014-01-17
Hi

I have this radio button list:
 <asp:RadioButtonList ID="rblRefer2Provider" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" ClientIDMode="Static">
 <asp:ListItem Text="No" onclick="toggleRefer2Provider2(false);" />
 <asp:ListItem Text="Yes" onclick="toggleRefer2Provider2(true);" />
</asp:RadioButtonList>

Open in new window


Based on another page event I want to select or de select the first item (The No) using JavaScript (not jquery)

I have tried document.getElementById('rblRefer2Provider_0').checked = true; but this doesn't work, but the radio button list doesn't render as such.

How do I do this. I have searched Google but nothing seems elegant or works.

Andy
0
Comment
Question by:Andy Green
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39787949
var radioContainer = document.getElementById('<%= rblRefer2Provider.ClientID %>');
var radioButtons = radioContainer.getElementsByTagName("input");
radioButtons[0].checked = true; // No

Open in new window

0
 
LVL 3

Author Closing Comment

by:Andy Green
ID: 39788070
Nice one thanks

Andy
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 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