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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:37:15+00:00 2026-06-09T13:37:15+00:00

I have 2 select lists mySelect and mySelect2. When one is selected if you

  • 0

I have 2 select lists mySelect and mySelect2.
When one is selected if you click on the checkbox the other changes simultaneously.

Please check code below:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

function displayResult() {
    if(document.form1.billingtoo.checked == true) {
        var x = document.getElementById("mySelect").selectedIndex;
        // Set selected index for mySelect2
        document.getElementById("mySelect2").selectedIndex = x;
   }
}

</script>
</head>
<body>

<form name="form1">
Select your favorite fruit:
    <select id="mySelect">
        <option>Apple</option>
        <option>Orange</option>
        <option>Pineapple</option>
        <option>Banana</option>
    </select>

    <br>

    <input type="checkbox" name="billingtoo" onclick="displayResult()">

    <br>

Select your favorite fruit 2:
    <select id="mySelect2">
        <option>Apple</option>
        <option>Orange</option>
        <option>Pineapple</option>
        <option>Banana</option>
    </select>

</form>
</body>
</html>

…how do I disable (grey out) mySelect2 so that you cannot make any changes any changes once the values are in place?

thanks.

  • 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-09T13:37:17+00:00Added an answer on June 9, 2026 at 1:37 pm

    Not sure why your question is tagged “jQuery” when you’re not using any, but still:

    // with "plain" JS:
    document.getElementById("mySelect2").disabled = true;
    
    // with jQuery
    $("#mySelect2").prop("disabled", true);
    

    Either way set the disabled back to false to re-enable the control.

    Here’s one of many ways to rewrite your function with jQuery:

    $(document).ready(function() {
        // bind the checkbox click handler here,
        // not in an inline onclick attribute:
        $('input[name="billingtoo"]').click(function() {
            var $mySelect2 = $("#mySelect2");
            // if checkbox is checked set the second select value to
            // the same as the first
            if (this.checked)
                $mySelect2.val( $("#mySelect").val() );
            // disable or re-enable select according to state of checkbox:
            $mySelect2.prop("disabled", this.checked);
        });
    });
    

    Demo: http://jsfiddle.net/nnnnnn/99TsC/

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

Sidebar

Related Questions

I have dropdown-Lists which have a lot of elements (>1000). When I select one
I have this dropdown. I need clone for my other dropdown lists: <select name=general>
I have 2 select lists. There is a check box that when it is
I have two select lists, I would like jquery to either remove or disable
Currently we have dueling select lists where you can select multiple employees from Available
I have a table with many rows and each row has select lists. Something
I have implenmented drop-down lists Select menus in jQuery Mobile. <div data-role=fieldcontain> <label for=name
i have this lists, and i want select li element from jquery when the
I have a dropdownlist which lists Country names When user select any country from
I have a HTML select list, which can have multiple selects: <select id=mySelect name=myList

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.