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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:31:34+00:00 2026-06-17T19:31:34+00:00

I have two select inputs with same options and changing value in first select

  • 0

I have two select inputs with same options and changing value in first select should disable all previous options in second (including) selected one, and set the value of second select to first next value.
I’ve setup a working fiddle here.

<select data-bind="options: selectList, value: firstSelect"></select>
<select data-bind="options: selectList, value: secondSelect, minVal: firstSelect"></select>

I have created custom binding handler:

ko.bindingHandlers.minVal = {
    update: function (element, valueAccessor) {
        var firstValue = ko.utils.unwrapObservable(valueAccessor());
        var firstNext=null;
        $(element).children().each(function () {
            var $this = $(this);
            if ($this.val() <= firstValue) {
                $this.attr('disabled', 'disabled');
            } else {
                if (firstNext==undefined){
                    firstNext=$this.val();
                }                
            }
        });
        $(element).val(firstNext).trigger('change');
    }
};

And it works in case that you change first select it will disable all previous options in second, and set the value of second to first next value, but the problem is when user wants to change value in second, it could not do because of update from custom binding is always setting up value according to first. So my question is how to know in custom binding how is updated value, from changing valueAccessor() observable or manually by changing second select?

  • 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-17T19:31:35+00:00Added an answer on June 17, 2026 at 7:31 pm

    I’ve find a solution, it was pure logical issue.
    Just before updating value ask if new value (selected manually form changed select option) is bigger than value that should be selected from custom binding and you will be able to change value to one that you want.

    if (firstNext >= $(element).val()) {
        $(element).val(firstNext);
        $(element).change();
    }
    

    Here is updated fiddle: http://jsfiddle.net/9gGjq/4/

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

Sidebar

Related Questions

I have two select boxes, the first select box has two options: First set
I have a drop down menu, with two options: <select name="chs" value="" id =
I have two select lists, I would like jquery to either remove or disable
So I have two multiple select boxes like this <select id=foo multiple=multiple> <option value=1>Option
I have two select controls that I want to populate with the exact same
I have two inputs with the same date, but i want to separate the
I have two select fields in a form. Every time one of these select
I have two select menus (#id1 and #id2) that, when validated as containing a
I have two select elements, A and B: when A's selected option changes, B's
I have two select queries to use in my project for getting data and

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.