Hide some of your field's multiple choice options based on value in other multiple choice

I have two multiple choice fields.  One is 'Status', and I want to hide one of the four options if the other multiple choice question hasn't been selected (i.e. it is still blank).  These are both found on the same page.

 

There are a couple of posts that come close to addressing this question, but they do not address how to set the condition based on the lack of selection in the other multiple choice field.

https://support.knack.com/hc/en-us/community/posts/115002369532-Hide-some-of-your-field-s-multiple-choice-options-on-specific-forms

https://support.knack.com/hc/en-us/community/posts/360067773452-How-to-filter-out-options-in-a-multiple-choice-list-based-on-user-role-

Hi Brian, 

Here is some example code:


//ADD VIEW ID
$(document).on('knack-view-render.view_XXX', function(event, view, data) {
    //DROPDOWN ID
    Knack.$('#view_XXX-field_XXX').on('change', function(){
        const fieldVal = Knack.$(this).val();

        //IF FIELD VALUE IS EQUAL TO STRING
        if(fieldVal === "XXXXXXXXXX"){
            //Hide option from other dropdown. Value = the option in the dropdown you want to hide
            Knack.$('#XXX-field_XXX option[value="XXXXX"]').hide();
            //If you want to hide an entire field
            Knack.$('#field_134').hide();

        //IF FIELD VALUE IS EQUAL TO ANOTHER STRING
        }else if(fieldVal === "XXXXXXXXXX"){
            Knack.$('#view_XXX-field_XXX option[value="XXXXXX"]').show();
            Knack.$('#XXXXX').show();
        }
    })
});

I hope this helps!

Kelson
kelson@ksensetech.com
https://www.ksensetech.com/knack/

Kelson - one dropdown menu has options , one of which must be selected in order for the ability to change from In Review to Approved (those are 2 of 4 lead statuses). For this reason, I don't want Approved to be in the list until they have made a selection in the other dropdow menu.

I can't use display rules because that only allows me to hide/show the whole multiple choice dropdown menu. Not options within the dropdown. I tried that, but maybe i missed something.

In the form display rules you will select hide/show or show/hide depending on how you want it to function. 

Hi Brian, 

If you still need help with this please reach out. I don't understand enough of your question to give you feedback. Here are my contact details:

Kelson
kelson@ksensetech.com
https://www.ksensetech.com/knack/

HI I need to hide one of four options in option field on a form, do you have solution for that with CSS
regards
Palmar

Hi guys, I have a use-case similar but different:

Company Y, Project X
Collaborators > Multiple choice options: show list of ALL collaborators of Company Y
Responsable > One choice options: show ONLY collaborators of Project X

So the Responsable dropdown must only show the selected colaborators of Project X.

This is useful for many things!

Any idea? thanks guys!

(the one or multiple choice aspect is defined in the builder object field atributes.)

An “easy way” to do it is to automaticaly show the selected Collaborators in the Responsable dropdown.

A more laborious way would be to compare each company collaborator in Responsable dropdown and hide it IF it does not match with one of the selected Collaborators.

This is a related entry that I am investigating…