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

  • Home
  • SEARCH
  • 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 5981881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:00:26+00:00 2026-05-22T22:00:26+00:00

I have two comboboxes on an form. Each has the values Yes and No.

  • 0

I have two comboboxes on an form. Each has the values Yes and No. What I want is when one is changed the other get the opposite (if the first is Yes the other is No).I need to do it with Javascript. I saw this question How to change "selected" value in combobox using JavaScript? but it is applied to only one combobox.

How can I do this?

LE:I need this example to be make with comboboxes. I can not use radio buttons

  • 1 1 Answer
  • 1 View
  • 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-22T22:00:26+00:00Added an answer on May 22, 2026 at 10:00 pm

    I created a simple jsFiddle Demo. This is not perfect, just illustrates the idea.

    HTML:

    <select id="first">
        <option value="0" selected>No</option>
        <option value="1">Yes</option>
    </select>
    
    <select id="second">
        <option value="0">No</option>
        <option value="1" selected>Yes</option>
    </select>
    

    Javascript:

    //find the selects in the DOM
    var first = document.getElementById('first');
    var second = document.getElementById('second');
    
    //this is the handler function we will run when change event occurs
    var handler = function () {
        //inside the handler, "this" should be the select 
        //whose change event we are currently handling
    
        //get the current value and invert it (0 -> 1, 1 -> 0)
        var invertedValue = this.value === '0' ? 1 : 0;
    
        //check which select's change we are currently handling
        //and set the inverted value as the other select's value
        if (this === first) {
            second.value = invertedValue;
        } else {
            first.value = invertedValue;
        }
    
    };
    
    //add handler function to run on change event on both selects
    first.addEventListener('change', handler, false);
    second.addEventListener('change', handler, false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a form that consist of two textfield and one combobox. i want
I currently have two comboboxes on a form. The first combobox contains a list
I have two form. One will display records form a RecordSet that the other
So I have two comboBoxes (comboBoxFromAccount and comboBoxToAccount). Each has the same datasource, which
I have two comboboxes: The first one is Language (English, Italian, French...) and the
I have two comboBoxes, one is CountryCombo and second is StateCombo. What I want
I have two applications written in Java that communicate with each other using XML
Im using c# .net windows form application. I have two comboboxes A and B
I have a form with two ComboBoxes. The second ComboBox holds a list of
I have a form that has two buttons, textbox, listbox, and a combobox. 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.