Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:37:52+00:00 2026-05-30T03:37:52+00:00

I have a TextBox next to a RadioButton , and when someone selects the

  • 0

I have a TextBox next to a RadioButton, and when someone selects the TextBox it should set the associated RadioButton as Selected.

I was using this code until I noticed it only worked for Chrome:

<asp:RadioButton runat="server" GroupName="SomeGroup" ID="rbOption3" />
<asp:Label runat="server" AssociatedControlID="rbOption3">
    <asp:Label runat="server" Text="Pay other amount" />
    <asp:TextBox runat="server" ID="txtOtherAmount" CssClass="money-text" />
    <div class="align-with-radiobutton small-text">
        The minimum amount for web payments is <asp:Label runat="server" ID="lblMinPayment" />. If you are looking to pay a lower
        amount, please <a href="Contact.aspx">contact us</a> and speak with a representative.
    </div>
</asp:Label>

enter image description here

It behaves differently in all 3 major browsers

IE: Selection does not change at all when TextBox is selected

FireFox: Selection changes on MouseUp, which means anytime you select the TextBox, the focus will change to the RadioButton, which makes it seem like the TextBox is not selectable

Chrome: Works fine since the selection changes on MouseDown

My requirement is that users can select any part of the Text, or the TextBox, and it will select the Radio Button.

How can I select an associated RadioButton whenever a TextBox gains focus, either from mouse or keyboard navigation?

Edit

The solution posted by rsbarro works for IE and Chrome, however it is still failing for FireFox. When you select the TextBox in FireFox, the RadioButton steals focus on MouseUp, which makes it look like the TextBox cannot be selected.

I tried using some jQuery, however the .changed() and .focus() don’t get fired when selecting the TextBox (they get fired when selecting the Label though), and I can’t seem to stop the event.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:37:54+00:00Added an answer on May 30, 2026 at 3:37 am

    The following approach worked for me in the latest versions of IE, Firefox, and Chrome:

    <script type="text/javascript">
        function selectRadio3() {
            var rb = document.getElementById('<%= rbOption3.ClientID %>');
            rb.checked = true;
        }
    
        function selectOtherAmount() {
            var txt = document.getElementById('<%= txtOtherAmount.ClientID %>');
            txt.focus();
        }
    </script>
    
    <asp:RadioButton runat="server" GroupName="SomeGroup" ID="rbOption3" onclick="javascript:selectOtherAmount()" />
    <asp:Label ID="Label1" runat="server" AssociatedControlID="txtOtherAmount" Text="Pay other amount" />
    <asp:TextBox runat="server" ID="txtOtherAmount" onfocus="javascript:selectRadio3()" CssClass="money-text" />
    <div class="align-with-radiobutton small-text" onclick="javascript:selectOtherAmount()">
        The minimum amount for web payments is <asp:Label runat="server" ID="lblMinPayment" />. If you are looking to pay a lower
        amount, please <a href="Contact.aspx">contact us</a> and speak with a representative.
    </div>
    

    I associated the Label with the TextBox, and I added javascript to set the checked property of the RadioButton when the TextBox gets the focus. I also added and onclick event on the RadioButton to set the focus to the TextBox.

    EDIT
    Using your original HTML and adding a little javascript worked for me as well. I added an onclick event to the RadioButton to set the focus to the TextBox, and an onfocus event on the TextBox to set the checked property of the RadioButton.

    <script type="text/javascript">
        function selectRadio3() {
            var rb = document.getElementById('<%= rbOption3.ClientID %>');
            rb.checked = true;
        }
    
        function selectOtherAmount() {
            var txt = document.getElementById('<%= txtOtherAmount.ClientID %>');
            txt.focus();
        }
    </script>
    
    <asp:RadioButton runat="server" GroupName="SomeGroup" ID="rbOption3" onclick="javascript:selectOtherAmount();" />
    <asp:Label ID="Label1" runat="server" AssociatedControlID="rbOption3">
        <asp:Label ID="Label2" runat="server" Text="Pay other amount" />
        <asp:TextBox runat="server" ID="txtOtherAmount" CssClass="money-text" onfocus="javascript:selectRadio3();" />
        <div class="align-with-radiobutton small-text">
            The minimum amount for web payments is <asp:Label runat="server" ID="lblMinPayment" />. If you are looking to pay a lower
            amount, please <a href="Contact.aspx">contact us</a> and speak with a representative.
        </div>
    </asp:Label>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox and a datepicker next to it and I am using
I have a textbox which should state how many buttons are selected. The problem
I have a textbox with an 'Add to clipboard' button next to it. Whenever
I have a textbox with an onchange event. Why does this event not fire
Let's say I have a simple TextBox next to a Label: <StackPanel> <StackPanel Orientation=Horizontal>
I have a textbox with a calendar icon next to it. When the icon
I have a textbox UserName and a Check Availability button next to it..... I
This is what I want: Let's say I have a textbox and a button
I have 2 textbox,1 spinnerview and 1 button in this Activity A. After the
i have a textbox on my form with a linkbutton next to it. the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.