hiding a panel with multiple conditions

  • 30 November 2017
  • 6 replies
  • 4 views

Badge +6

Hello! I have a question about a formula for hiding a panel with multiple conditions. I've attached a document with screenshots and details. Any help would be greatly appreciated.


6 replies

Userlevel 5
Badge +14

I have simplified the control names a bit, but you should be able to follow. 

!(jobType === "Member/Marketing/Community/Org." || 
    (jobType === "Health Promotion (Disease Management)" &&
      HP_Job_NewProject === "No"))

This way. 

If the jobType equals "Member/Marketing/Community/Org." (true), then it gets inverted to (false), revealing the control

if the jobType equals "Health Promotion (Disease Management)" (true) 
AND 

if the HP_Job_NewProject equals "No" (true) 

THEN 

it results in a true statement, which gets inverted to false, revealing the control. 

Every other option will hide the panel. 


Badge +6

‌ it worked! Thank you so much! What is the significance of the === as compared to the ==?

Userlevel 5
Badge +14

Glad to hear that it worked out!

If possible, could you mark my answer as correct? 

As for the == and ===, the only difference is that === checks the type while == doesn't. 

Now... I warn you before you continue. This is boring programming / JavaScript stuff, and for anyone reading who just doesn't care about that type of thing, it might be best to turn back now! Otherwise, you might go to sleep... 

... Still there? Great! 

What is a type? It is what it sounds like! It's the 'type' of data that you're checking. In JavaScript there are only a few data types. They are - Boolean, Number, String, Symbol, Null, and Undefined. There is also another type called Object. 

You can learn more about Types here: JavaScript Data Types 

You've already used some of these types in your work. 

"Hello I Am A Sentence" is a String (notice the quotes), while... 

4 is a Number. 

The reason that you might want to use one over the other though... well that's where it gets a little more... philosophical.


Using something like == means that the statement 

4 == "4"

equals true, which is the equivalent of saying, "The Number 4 is equal to the Word 4"! Using only == means that javascript doesn't care about the fact that one is a Number and the other is a String... However... 

4 === "4"

equals false, because it not only checks the values of the data being compared, but the types of those values! This is just like the sentence above, only with the types un-marked out. "The Number 4 is equal to the Word 4"!

For further reading on the subject. Look here Difference between == and === Equal Operator in JavaScript | Java67 

------------

Outro:

------------
Most of this is really only important when you're doing heavier JavaScript work where you are expecting certain values to be of certain types (my currency field probably shouldn't have words written in there!), however, because JavaScript is so chaotic (ie... kinda brokenish), there have been a few humans who have attempted to create a set of syntax standards, aka: Coding Conventions, which aide in preventing errors from happening in code where it otherwise would if there weren't any standards! 

Using ===, !==, "" (instead of single quotes), and a bevy of other things are part of a standard that I use to make sure that my code is consistent and correct. All of my own used conventions come from Douglas Crockford, who is a guru of the language (and might understand better than anyone at this point). 

 

Badge +6

 Thank you very much. I wonder if this might help in some of required formulas I'll work on those next week.

Userlevel 5
Badge +14

One thing that I would recommend would be to name your controls with much shorter (and even more generic) names. 

It really helps to narrow down exactly what it is you're working with when what you're looking at isn't a long list of characters! 

The forums will be here if you run into any more speed-bumps!

Badge +6

 Thank you

Reply