Objective
I'm trying to create a form that will display different dropdown(select) lists based on a single first choice of "Plan Type" e.g.("Basic", "Standard", "Deluxe").
If a user selects "Basic", then the user can choose from a new dropdown list called "Option A". If they select "Standard" or "Deluxe" then they receive "Option B".
Edit to Objective
I guess I just really need to have the isOptionA or isOptionB available for consumption in my view.
Requirement
The user can only see the options that they have selected, I do not want to show disabled fields of any kind (reason: its a bad experience for basic users, IMO).
Also, the options in all dropdowns are not to be changed by the user at any point in time.
Past Research
I've crawled all sorts of sites, including SO. None of them can help me put it all together.
HTML
<div>
<select id="planType" data-bind="options: planTypes, value: selectedPlanType, optionsText : 'name', optionsValue : 'id', optionsCaption : 'Select your Plan'"></select>
</div>
<div data-bind="if: isOptionA">
Option A Available!
</div>
Knockout JS
var viewModel = function(){
var self = this;
self.planTypes = [
{ id: 0, name: 'Basic', optionA: false, optionB: true },
{ id: 1, name: 'Standard', optionA: true, optionB: false },
{ id: 2, name: 'Deluxe', optionA: true, optionB: false }
];
self.selectedPlanType = ko.observable();
self.isOptionA = ko.computed(function(){
//pass the currently selected plan type's boolean for optionA to
//'isOptionA'
});
self.isOptionB = ko.computed(function(){
//pass the currently selected plan type's boolean for optionB to
//'isOptionB'
});
};
ko.applyBindings(viewModel);
Please view my js fiddle here and lend help if you can.