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.
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.
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.
Didn’t succeed to make work the code above on radioDependancy.
As instructed I just put the corresponding ID (field_yy is the drop down, field_zz is the radio button list in) in this line, but does nothing.
$(document).on(‘knack-view-render.view_xx’, function(event, scene, record) {
radioDependancy(“view_xx”, “field_yy”, “field_zz”);
I had a similar situation. I have a dropdown field (field_1253) where if the option selected is “Rent” then it hides select options in (field_2977) which are single-choice radio buttons. The following code worked for me. Hope this helps!
// This function hides or shows radio options based on the controlling field
const updateOptions = function() {
const controllingValue = $('select[name="field_1253"]').val();
const shouldHide = controllingValue === 'Rent';
optionsToHide.forEach(option => {
const radioOption = $(`input[name="${fieldToChange}"][value="${option}"]`);
if (radioOption.length) {
const parentDiv = radioOption.closest('.control');
parentDiv.css('display', shouldHide ? 'none' : 'block');
}
});
};
// Attach event listener to update options when the controlling field changes
$('select[name="field_1253"]').change(updateOptions);
// Call the function to set the initial state
updateOptions();
and if you want to hide radio-button selections based on the view you can use the following:
$(document).on(‘knack-view-render.view_2027’, function(event, view) {
const fieldToChange = ‘view_2027-field_2977’; // Change to your field ID
const optionsToHide = [‘Buyer’, ‘Seller’]; // Replace with your actual options
// This function hides or shows radio options
const updateOptions = function() {
optionsToHide.forEach(option => {
const radioOption = $(`input[name="${fieldToChange}"][value="${option}"]`);
if (radioOption.length) {
const parentDiv = radioOption.closest('.control');
parentDiv.css('display', 'none');
}
});
}
updateOptions(); // Call the function when view is rendered