If selected: hide
-
Hi there,
I’m finding as my form becomes more complex, that I need multiple layers of show/hide logic. While the plugin does a good job with built-in logic to ‘show’ fields based on a selection, there are instances where I will need to ‘hide’ or ‘rehide’ a shown field, based on whether a checkbox item is checked or dropdown item is selected.
Is there an easy way to do this?
Thank you.
-
To give an example, I have logic that ‘shows’ a fieldset when a certain dropdown is selected, but the contents nested within the fieldset may all be hidden.
In the case where all elements in a fieldset are hidden, I want to re-hide the fieldset as well. Otherwise it shows up as an empty square with a label.
Hello,
I don’t understand totally your dependency rules, but if you need to implement very complex dependency rules, I recommend to use calculated fields as auxiliary fields.
In the equation of the calculated field you can check the possible conditions and return an unique value depending of conditions, and then, define the dependency rules based on the equation’s result.
Best regards.
I like the way you think. Perhaps this is a better question then.
How do I tell a calculation not to calculate if the value of a checkbox on my form is a certain value?
For example, I have a checkbox with the following values
red
yellow
green
blueHow do I tell my calculated field not to calculate if the value = ‘blue’, and tell a fieldset to hide if value = blue?
I’m hoping a calculation can override the CSS show/hide values.
-
This reply was modified 9 years, 4 months ago by
chadtesting.
-
This reply was modified 9 years, 4 months ago by
chadtesting.
-
This reply was modified 9 years, 4 months ago by
chadtesting.
-
This reply was modified 9 years, 4 months ago by
chadtesting.
-
This reply was modified 9 years, 4 months ago by
chadtesting.
Hello,
The equations are always evaluated if the fields that participate in the equation vary, however, you can return a value or another based on the choice selected. By the way, if you want limit the selection to one choice, you should use radio buttons instead checkboxes.
However, assuming you want use checkboxes (the fieldname1 field), and you want hide the fieldset(the fieldname2) if the “blue” choice was selected.
Implements an equation similar to:
(function(){ if(/blue/i.test(fieldname1)) return 1; return 2; })()The returned values are hypothetical, only to explain the process.
Now, in the dependencies section, select the option: “Not equal to”, enter the number 1 as the value, and select the fieldname2 field as the dependent field.
Best regards.
Ahh man that’s so clever.
By the way, I want to bring something to your attention from a previous ticket you addressed.
When creating a button that makes a dropdown visible, but makes other dropdowns invisible, you gave me the following code
jQuery(‘.foods’).show();
jQuery(‘.nursing’).hide();
jQuery(‘.socialsci’).hide();
jQuery(‘.hide’).removeClass(‘hide’);This works, but what it also does is removes the ‘hide’ from my fieldsets further down in the form. This was driving me nuts because I couldn’t figure out why my hidden fields were suddenly showing up for no reason.
Is there a way to remove the hide class from the field, without removing ‘hide’ from my fieldsets? I didn’t realize one would affect the other.
Hello,
The code you are referring display all fields, because removes the class “hide” from the fields, and the “hide” class is a special class in the plugin that applies the css rule: display:none; to the fields where is applied:
jQuery('.hide').removeClass('hide');Remember, I have gave you only ideas that you should adjust to your project.
If you need the real implementation of your project, I can offer you a custom coding service.
http://cff.dwbooster.com/customization
Best regards.
Hi codepeople, I was able to figure it out. I was unnecessarily hiding fields.
The more I learn, the more I have to go back and fix mistakes I made previously, but this is helping. Thank you.
I will no doubt be upgrading to developer at the end of this month.
-
This reply was modified 9 years, 4 months ago by
chadtesting.
-
This reply was modified 9 years, 4 months ago by
The topic ‘If selected: hide’ is closed to new replies.