Results 1 to 12 of 12

Thread: *Resolved* Select Radio Button When Text Next to it is Clicked

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    *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

  2. #2
    Addicted Member
    Join Date
    Nov 2004
    Posts
    149

    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    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 ...

  4. #4
    Addicted Member
    Join Date
    Nov 2004
    Posts
    149

    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

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Question 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 ...

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Unhappy 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">&nbsp;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">&nbsp;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?

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Thumbs up 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!

  9. #9
    New Member
    Join Date
    Mar 2005
    Posts
    6

    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

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Thumbs up Re: Select Radio Button When Text Next to it is Clicked

    syntax-error, I'll do some research on a LinkLabel.

    Thanks, OS (OneSource!)

  11. #11
    New Member
    Join Date
    Mar 2005
    Posts
    6

    Resolved 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/

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    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
  •  



Click Here to Expand Forum to Full Width