Solved

set radiobuttonlist with javascript

Posted on 2014-01-17
2
352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

740 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