Solved

set radiobuttonlist with javascript

Posted on 2014-01-17
2
349 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…
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…

770 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