You are viewing limited content. For full access, please sign in.

Question

Question

Hide or show a field based on drop down choice from a DB look up

asked on May 22, 2019

Could someone provide me with an example of JavaScript that would un-hide a field ("Name") upon a specific choice picked out of a drop down field ("Seasonal Employee") that provides a list from a DB look up?  I have found I cannot create a Field Rule to make the Name field show up if the Seasonal Employee choice is picked out of the look up list, because the field rule can't see the drop down choices yet.

0 0

Answer

SELECTED ANSWER
replied on May 22, 2019 Show version history

You don't set the Calculation equal to "Seasonal Employee"

You set the Calculation equal to your drop down variable, and you use the Single Line field for the Field Rule, not the drop down.

In the Field Rule, you can manually enter "Seasonal Employee" when you have it pointed at the Single Line.

Basically, you can't do what you want with the drop down directly, so the Single Line with the Calculation gives you an indirect way to reference the drop down value.

See below (use the > button to select the actual variable name for your drop down)

0 0

Replies

replied on May 22, 2019 Show version history

The workaround for using Field Rules is as follows.

  1. Create a hidden Single Line field
  2. In the advanced tab of the field
    • Add a Calculation that sets it equal to your dropdown variable
  3. In the Field rules, set it to Hide/Show based on the value of the hidden Single Line
    • Manually enter the "trigger" value (i.e., "Seasonal Employee")

 

If you use JavaScript, you would need to hard-code the value anyway; this approach requires less customization and still uses the built-in hide/show functionality.

0 0
replied on May 22, 2019

Thanks, Jason!

Question 1 - How do you set a "Calculation" to equal "Seasonal Employee"?

Question 2 - so in the Field Rules, I would be telling it to Show the Name field only if ...  ... no, I still can't tell it to show the name field only if the drop down field is Seasonal Employee.  Um, maybe this part is dependent on the Calculation?

I need the submitter to be able to tell me that the Employee (drop down look up) is a Seasonal Employee instead of picking a regular employee name out of the Look Up list and then I want to provide him with an additional field (Name field, single line) where he can manually type in the Name of the seasonal (temporary) employee.

0 0
SELECTED ANSWER
replied on May 22, 2019 Show version history

You don't set the Calculation equal to "Seasonal Employee"

You set the Calculation equal to your drop down variable, and you use the Single Line field for the Field Rule, not the drop down.

In the Field Rule, you can manually enter "Seasonal Employee" when you have it pointed at the Single Line.

Basically, you can't do what you want with the drop down directly, so the Single Line with the Calculation gives you an indirect way to reference the drop down value.

See below (use the > button to select the actual variable name for your drop down)

0 0
replied on May 22, 2019

Thanks, Jason!  I got it working.  I didn't realize the hidden single line field you were talking about wasn't the same field I was using for the Name field.  Now I have two hidden fields.  One that will ALWAYS remain hidden and just populates the users choice in the drop down field.  Then, the hidden Name field will only show if the choice that ends up in the always hidden field turns out to be Seasonal Employee.

It works!  Thanks so much!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.