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 8120949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:19:29+00:00 2026-06-06T05:19:29+00:00

I have 2 radio buttons and 2 input fields. I want to associate a

  • 0

I have 2 radio buttons and 2 input fields. I want to associate a radio button with an input field, so only the selected radio button’s input field is enabled and others are disabled.

My html markup is:

<div>
    <input type="radio" checked="checked" name="co" data-for="s" />
    <input type="text" id="s" />
    <br /><br />

    <input type="radio" name="co" data-for="u"/>
    <input type="text" id="u" disabled="disabled" />
</div>

So currently the first radio button is checked, and its input field is enabled. How can I do this with a bit of jquery code?

EDIT

I tried this:

$("input[type=radio][name=co]").bind({
  change: function () { 
    if ($(this).attr("checked") == "checked")
       $("#" + $(this).attr("data-for")).removeAttr("disabled"); 
    else 
       $("#" + $(this).attr("data-for")).attr("disabled", "disabled"); 
  } 
});
  • 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-06-06T05:19:31+00:00Added an answer on June 6, 2026 at 5:19 am

    Try this – http://jsfiddle.net/DMasH/

    $("input:radio").on("click", function() {
        $("input:text").attr("disabled", true);
    
        $(this).next("input").attr("disabled", false)
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form. Input fields, checkboxes, radio buttons and finally SUBMIT button.
I have a form that sets input fields as enabled / disabled based on
I have the form with a number of input fields, text areas, radio buttons,
I have this radio buttons in html code: <span><input type=radio value=false name=item[shipping] id=item_shipping_false checked=checked><label
I have several text input fields in my page, and few radio buttons. Now
I have a list of input type radio buttons in formview (edit mode) and
I have 2 radio buttons, what I want is if a user selects the
I want to toggle two radio buttons and select fields based on which radio
I have a JSP/HTML form with text box and radio buttons. I am saving
on jQuery UI you can transform checkboxes or radio fields to buttons -> http://jqueryui.com/demos/button/#radio

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.