473,396 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add onclick javascript code to each radio button in a RadioButtonList control

Hello.

I am having another issue. I need to execute some JavaScript whenever a
radio button is clicked. I am currently using a RadioButtonList control to
generate the radio buttons because of its excellent ability to be bound to a
datasource. No matter what I do though, I am not able to add an onclick
event to the individual radio buttons in the page. How might I go about
this? Currently I have

private void Questions_OnItemDataBound(object sender, RepeaterItemEventArgs
e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
RadioButtonList rbl = (RadioButtonList)
e.Item.FindControl("AnswerOptions");
rbl.DataTextField="fullOptionDescription";
rbl.DataValueField="answerOptionId";
rbl.DataSource = ((DataRowView)
e.Item.DataItem).CreateChildView("questionId");
rbl.DataBind();

foreach(ListItem li in rbl.Items)
li.Attributes.Add("OnClick", "needToConfirm = true;");
}
}

I've tried other variants as well with no success.

Thanks in advance.
Ryan Taylor
Nov 18 '05 #1
0 2185

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function...
5
by: Gerard van Wilgen | last post by:
I noticed that the following line of code works in IE 6 but not in Netscape 7.1: <INPUT TYPE="radio" NAME="selComb" VALUE="0" ONCLICK="alert(selComb.value)"> Nothing happens when I click on...
5
by: johnsuth | last post by:
I want to produce a trivial demonstration of dynamic modification. I thought that pressing a button might change its color. I studied O'Reillys books and successfully created the button with a...
3
by: Dot net work | last post by:
Is it possible to have a radiobuttonlist control appear on a webform without any radio buttons checked to begin with? I would really like to make sure that the user specifically chooses a radio...
5
by: dighazuse | last post by:
trying to get a javascript attached to a DataGrid RadioButtonList. I have a similar thing working for a DDL so i copied that for the RBL. It "errors" when i am trying to get the current selected...
1
by: dickson.matt | last post by:
OK, I am checking the values of a radiobuttonlist with 2 values (Yes and No) using javascript: <table id="optMedTreatment"...
2
by: DataSmash | last post by:
Hello, I've created a simple form with 2 radio boxes, 2 text boxes and a button. When I click the button, I'd like to write each "choice" to a text file. I can't figure out how to "link" the...
2
by: Jeff | last post by:
I'm still new to all of this - mostly vb.net using vs 2005, so I might not be using good terminology but let me give my question a try: I'm looking for someone to point me in the correct...
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.