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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:40:51+00:00 2026-05-26T19:40:51+00:00

I want to toggle two radio buttons and select fields based on which radio

  • 0

I want to toggle two radio buttons and select fields based on which radio button is selected. I have the jQuery working, but want to know if there is a way to make it more efficient. Seems like quite a few lines for the simple goal I am trying to achieve. Here are the requirements:
when the page loads, #aircraftType should be checked and #aircraftModelSelect should be grayed out (right now, the “checked” is being ignored by Firefox).
If the user clicks either #aircraftType or #aircraftModel, the opposite select field should become disabled (if #aircraftModel is checked, #aircraftTypeSelect should be disabled, and vise versa). Any help on optimizing this code is appreciated.

Code is up on jsfiddle too: http://jsfiddle.net/JuRKn/

    $("#aircraftType").attr("checked");
    $("#aircraftModel").removeAttr("checked");
    $("#aircraftModelSelect").attr("disabled","disabled").addClass("disabled");
    $("#aircraftType").click(function(){
      $("#aircraftModelSelect").attr("disabled","disabled").addClass("disabled");
      $("#aircraftTypeSelect").removeAttr("disabled").removeClass("disabled");
    });
    $("#aircraftModel").click(function(){
      $("#aircraftTypeSelect").attr("disabled","disabled").addClass("disabled");
      $("#aircraftModelSelect").removeAttr("disabled").removeClass("disabled");
    });

HTML

<div class="aircraftType">
  <input type="radio" id="aircraftType" name="aircraft" checked />
  <label for="aircraftType">Aircraft Type</label>
  <select size="6" multiple="multiple" id="aircraftTypeSelect" name="aircraftType">
    <option value="">Light Jet</option>
    <option value="">Mid-Size Jet</option>
    <option value="">Super-Mid Jet</option>
    <option value="">Heavy Jet</option>
    <option value="">Turbo-Prop</option>
  </select>
</div>
<div class="aircraftModel">
  <input type="radio" id="aircraftModel" name="aircraft" />
  <label for="aircraftModel">Aircraft Model</label>
  <select size="6" multiple="multiple" id="aircraftModelSelect" name="aircraftModel">
    <option value="">Astra SP</option>
    <option value="">Beechjet 400</option>
    <option value="">Beechjet 400A</option>
    <option value="">Challenger 300</option>
    <option value="">Challenger 600</option>
    <option value="">Challenger 603</option>
    <option value="">Challenger 604</option>
    <option value="">Challenger 605</option>
    <option value="">Citation Bravo</option>
  </select>
</div>
  • 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-26T19:40:52+00:00Added an answer on May 26, 2026 at 7:40 pm

    @Jim H. yes that is true but he can also do this with javascript…

    The first problem is that you don’t set checked to something (like Jim H. said above)

    The second problem is that you removed the attribute checked from an element with the same name after you added it to another element (this will remove the attribute on the first element too)

    $("#aircraftModel").removeAttr("checked"); //place this first
    $("#aircraftType").attr("checked", "checked"); //and then this
    

    Look here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two toggle buttons that I want to link together so that pressing
I have an application based on CoreDataBooks. I want to toggle two images in
I want to toggle a process's visibility at runtime , I have a Windows
I have a div that I want to toggle between displaying or not when
I want to create a toggle button in html using css. I want it
I have a ListBox control that I want to change into having a toggle
I have blocks of content that are toggled on/off via jQuery and I want
I have two div columns sidebar(left) and page-content(right). I toggle removing and adding 'sidebar'
I want the following requirement. But there is slight change on it. http://acrisdesign.com/demo/toggle/ Please
I have a basic newsletter signup form with an email field and two buttons

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.