Hello @suaveyg
Could you please include the link to the page that contains the form and indicate which fields you want to display based on the equations’ results?
Please, note that if you used the "Hidden" control or "Calculated Field" control with the choice “Hide Field From the Public Page” ticked, the plugin creates them with <input type="hidden"> tags. An input tag with type="hidden" cannot become visible. In this case, the alternative would be to assign the hide class name into the “Add CSS Layout Keywords” attribute of the field calculated field you want to make visible by code.
Best regards.
Thank you for your response. the page link is : https://designingote.com/bcfc/
one of the methods I was going to use was the hide class followed by the code:(“.classname”).removeClass(“hide”);
but at the moment, the conditional statement won’t even work as expected before I customize the actions.
I was looking to get the value of fieldname26 and based on that value, i would hide/show fieldname20 through to fieldname22.
So if fieldname26 was greater than 0, then display fieldname20(class .poscf)
if fieldname26 was less than 0, then display fieldname21(class .negcf)
if fieldname26 was equal to 0, then display fieldname22(class .neucf)
fields 20 through to 22 would be hidden by default by either using css display: none or the suggestion you mentioned which was the hide class.
calculation would be on the calculate button (fieldname19) where all of this would take place.
Cheers!
Hello @suaveyg
I’ll assume you want only to show/hide the fields and not activate/ignore them. So, I’ll use the SHOWFIELD and HIDEFIELD operations (To activate/ignore fields you should use the ACTIVATEFIELD and IGNOREFIELD operations, respectively)
Insert a calculated field as an auxiliary field in the form, that you can configure as hidden by ticking a checkbox in its settings, and enter the equation:
(function(){
HIDEFIELD(fieldname20|n);
HIDEFIELD(fieldname21|n);
HIDEFIELD(fieldname22|n);
if(0<fieldname26) SHOWFIELD(fieldname20|n);
if(fieldname26<0) SHOWFIELD(fieldname21|n);
if(fieldname26==0)SHOWFIELD(fieldname22|n);
})()
Best regards.
I have tried the auxiliary approach, and that works as you have mentioned in a dynamic way. However, I was trying to get the conditional logic working on a calculate button (fieldname 19) where the function will only initiate on an onclick event. That has been my struggle up to this point to get working. Is it still possible to utilize this showfield/hidefield concept on this calculate button type? After trying to implement pieces of this concept on the button, it will not work in any way expected.
Very much appreciating your help codepeople
Cheers!
Hello @suaveyg
If you want to implement the code below as the onclick event of the button:
(function(){
HIDEFIELD(fieldname20|n);
HIDEFIELD(fieldname21|n);
HIDEFIELD(fieldname22|n);
if(0<fieldname26) SHOWFIELD(fieldname20|n);
if(fieldname26<0) SHOWFIELD(fieldname21|n);
if(fieldname26==0)SHOWFIELD(fieldname22|n);
})()
Since you cannot access the fields’ values by their names outside the context of the equations, you must use the getField operation and its val method.
The onclick event would be:
HIDEFIELD('fieldname20');
HIDEFIELD('fieldname21');
HIDEFIELD('fieldname22');
let v = getField('fieldname26').val();
if(0<v) SHOWFIELD('fieldname20');
if(v<0) SHOWFIELD('fieldname21');
if(v==0)SHOWFIELD('fieldname22');
Best regards.