|
-
Mar 24th, 2005, 04:32 PM
#1
Thread Starter
Fanatic Member
*Resolved* Select Radio Button When Text Next to it is Clicked
Hi ....
What I'm trying to do should be simple. I have two radio buttons on an aspx page with text beside each explaining what the radio buttons mean. Of course, the radio buttons work correctly when clicked. Here's what I want to do ... when the text next to a radio button is clicked, I want the radio button itself to be selected. I've tried label and text box controls, but neither has a click event. Does anyone know how to do this?
Thanks,
OneSource
Last edited by OneSource; Apr 4th, 2005 at 07:18 AM.
Reason: Resolution
-
Mar 24th, 2005, 04:39 PM
#2
Addicted Member
Re: Select Radio Button When Text Next to it is Clicked
My radio buttons seem to work exactly how you describe you want them to work. The text next to the radiobutton selects the radio button when clicked.
I'm not trying to be rude, but you set the text for the radio button properly right? the radiobutton has a text property and radiobutton lists has an item collection.
-
Mar 24th, 2005, 04:55 PM
#3
Thread Starter
Fanatic Member
Re: Select Radio Button When Text Next to it is Clicked
token, I thought that I was going to be a candidate for the duh! award, but this isn't an asp:radiobutton control. It's of the type INPUT type="radio", which doesn't have a text property. So, I still don't know how to do it ...
-
Mar 24th, 2005, 05:07 PM
#4
Addicted Member
Re: Select Radio Button When Text Next to it is Clicked
oooh, sorry man, i wish that i could help. I have no idea, i dont have time now to try it out, if it is really important maybe you can create some javascript that will change the property of the radiobutton when you click the text after you make it a link. Seems like a whole lot of work for very little.
Is there any particular reason why you dont want to use the asp radio button control
-
Mar 24th, 2005, 05:23 PM
#5
Thread Starter
Fanatic Member
Re: Select Radio Button When Text Next to it is Clicked
Is there any particular reason why you dont want to use the asp radio button control
I'm taking over this app that was created by a different developer; therefore, I don't want to play around with it too much because something may break ...
-
Mar 24th, 2005, 10:46 PM
#6
Re: Select Radio Button When Text Next to it is Clicked
Place the text next to the radio button in a div tag. In the onClick event for the div, toggle the radio button using client side javascript.
-
Apr 1st, 2005, 02:52 PM
#7
Thread Starter
Fanatic Member
mendhak ...
thanks for your reply. I'm still struggling with this silly thing! I say silly because it should be so simple. Here's a snippet of my code:
Code:
<script language="javascript">
function SelectDoNotAccept(){
alert("test");
}
function SelectAccept(){
alert("test");
}
</script>
<TABLE id="Table2" cellSpacing="0" cellPadding="0" width="80%" border="0">
<TR>
<TD>
<P>
<INPUT type="radio" onclick="document.Form1.btnAcceptTerms.disabled=false" runat="server"
id="radbtnAcceptTerms" VALUE="radbtnAcceptTerms" NAME="RadioGroup"><span onClick="SelectAccept"> I accept these terms.</span><BR>
<INPUT type="radio" onclick="document.Form1.btnAcceptTerms.disabled=false" runat="server"
id="radbtnRejectTerms" VALUE="radbtnRejectTerms" NAME="RadioGroup"><span onClick="SelectDoNotAccept"> I DO NOT accept these terms.</span>
</P>
</TD>
</TR>
</TABLE>
As you can see, I used span instead of DIV because I got an error message saying that the Div can't be nested inside <P>.
The strange thing is that the code above works in a separate HTML document. When I put it in an aspx web page, I get a Javascript error saying object expected. Any ideas, anyone?
-
Apr 1st, 2005, 03:00 PM
#8
Thread Starter
Fanatic Member
Re: Select Radio Button When Text Next to it is Clicked
mendhak et all ... I figured out what the problem was! a silly "}" missing in the javascript code! arghhhh .... I said it was silly!
Thanks anyway!
-
Apr 1st, 2005, 11:33 PM
#9
New Member
Re: Select Radio Button When Text Next to it is Clicked
you could make it a lot easier on yourself and just use a LinkLabel to display the text, then do myradiobutton.Select in the click event for the LinkLabel
-
Apr 2nd, 2005, 07:30 AM
#10
Thread Starter
Fanatic Member
Re: Select Radio Button When Text Next to it is Clicked
syntax-error, I'll do some research on a LinkLabel.
Thanks, OS (OneSource!)
-
Apr 2nd, 2005, 10:41 AM
#11
New Member
Re: Select Radio Button When Text Next to it is Clicked
Check out a video on the LinkLabel control at VB @ the Movies (its in the "Controls" section),
http://msdn.microsoft.com/vbasic/atthemovies/
-
Apr 4th, 2005, 02:06 PM
#12
Thread Starter
Fanatic Member
Re: *Resolved* Select Radio Button When Text Next to it is Clicked
Thanks syntax-error, I didn't know about VB @ The Movies!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|