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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:25:12+00:00 2026-06-05T22:25:12+00:00

I am trying to create a group of dropdowns using knockout out that allow

  • 0

I am trying to create a group of dropdowns using knockout out that allow users to select up to 3 values from a list e.g. colours. The list starts as:- Red,orange,yellow,green,blue,indigo,violet

DropDown 1 - Select any of the 7
DropDown 2 - Select any of the 6 remaining
Dropdown 3 - Select any of the 5 remaining

If the user goes back and changes DropDown 1 to something they should only have the choices of the other remaining colours (and the one in Drop Down 1). If they then change it, I would be able to go to dropdown 2 or 3 and change that to the value that used to be in 1.

I think I need an initial array containing the 7 items, then I need an observable per dropdown. The 3 obseravables would have to be based on the initial data and excluding the selected of the other three dropdowns. I am really struggling with this. I can’t even come close to implementing it.

Is this even possible or an appropriate use for Knockout or should I just look at JS with an onChange

  • 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-05T22:25:13+00:00Added an answer on June 5, 2026 at 10:25 pm

    This is definitely possible in Knockout. And there’s probably 10 ways to do it. I’ve come up with one way here:

    http://jsfiddle.net/mbest/wfW97/

    Here’s the code for reference:

    function ViewModel() {
        var self = this;
        self.colors = ['red','orange','yellow','green','blue','indigo','violet'];
        self.selections = [];
        ko.utils.arrayForEach(self.colors, function() {
            self.selections.push(ko.observable());
        });
        self.selfAndUnselectedColors = function(index) {
            var selfColor = self.selections[index]();
            return ko.utils.arrayFilter(self.colors, function(color) {
                return color === selfColor || !ko.utils.arrayFirst(self.selections, function(sel) {
                    return color === sel();
                });
            });
        }
    }
    ko.applyBindings(new ViewModel());
    

    And HTML:

    <div data-bind="repeat: colors.length">
        <select data-bind="options: selfAndUnselectedColors($index), optionsCaption: 'select a color', value: selections[$index]"></select>
    </div>​
    

    I’m using my repeat binding plugin to create the repeated select elements, but you could use some other method if you wanted.

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

Sidebar

Related Questions

I'm trying to create a table of users that are part of a group
Im trying to create a password protected peer group using JXTA. For that i
I'm trying to create a data extractor algoritm from group buying sites to build
I am trying to create a report that has a summary for each group.
I'm trying to create a query that will group results BY where the grouped
I am trying to create a histogram data using following query: SELECT FLOOR(Max_Irrad/10) AS
I am trying to figure out a way to create a class to group
I'm trying to create a (sqlite) query that will perform a GROUP BY but
I'm trying to create a SharePoint web part that will display all the users
Basically, I'm trying to create a dynamic group of check boxes that are keyed

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.