473,626 Members | 3,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_OnIte mDataBound(obje ct sender, RepeaterItemEve ntArgs
e)
{
if (e.Item.ItemTyp e == ListItemType.It em || e.Item.ItemType ==
ListItemType.Al ternatingItem)
{
RadioButtonList rbl = (RadioButtonLis t)
e.Item.FindCont rol("AnswerOpti ons");
rbl.DataTextFie ld="fullOptionD escription";
rbl.DataValueFi eld="answerOpti onId";
rbl.DataSource = ((DataRowView)
e.Item.DataItem ).CreateChildVi ew("questionId" );
rbl.DataBind();

foreach(ListIte m li in rbl.Items)
li.Attributes.A dd("OnClick", "needToConf irm = true;");
}
}

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

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

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

Similar topics

8
3679
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 and passes it two parameters. For the life of me I cannot figure out what the error is, but one occurs everytime I click a &%*$&# radio button. Also, the function only alerts the user immediately as to what question/answer they clicked. I am...
5
1457
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 the radio button. There is not even an error message. This is a simplified version of the actual code, which is used to pass among
5
17684
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 fancy style, but the onclick fails to do anything no matter what permutation of parameters I try. <input type=button style=background-color:yellow;color:blue;font-family:Arial;font-style:italic;font-weight:bold name="xyz" value="CHANGE COLOUR"...
3
1782
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 button choice, rather than just accept the default value, which is the first radio button in the list being checked. TIA, -dnw.
5
6256
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 value for the RBL. code in ItemDataBound: rblDC.Attributes.Add("onClick", "rblDC_onClick('" + lblDC.ClientID + "', '" + rblDCodes.ClientID + "', '" + e.Item.ItemType + "')");
1
13962
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" onClick="SetFocusDayPhone(document.getElementsByName('optMedTreatment'))"> <tr> <td><input id="optMedTreatment_0" type="radio" name="optMedTreatment" value="Yes" /><label for="optMedTreatment_0">Yes</label></td> </tr><tr> <td><input id="optMedTreatment_1" type="radio" name="optMedTreatment"
2
2220
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 onClick event to the other 4 controls. Any help would be much appreciated! R.D. Harles
2
1142
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 direction by giving me the phrase or terminology I need to look up the specifics myself. I just don't know where to start. Here is task - On a web page, I need to switch between two images when the user clicks the
1
4076
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 hotspots on the image. One being correct(a) and the other incorrect(b). When the user clicks on the correct hotspot or place on the image, it should score and retain that value until the end of the quiz. At the end of the quiz, there is a submit button...
0
8262
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8701
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.