Solved

set radiobuttonlist with javascript

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

760 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

18 Experts available now in Live!

Get 1:1 Help Now