Skip to main content
Participant
September 23, 2020
Answered

Have a calculated dropdown box default to top option when clicking away from dropdown

  • September 23, 2020
  • 2 replies
  • 1215 views

I am having issues with a calculated dropdown box. The dropdown box (D2) is being calculated based off of the value of another dropdown (D1) on my form. For example, if D1 = "View Only" then the options in D2 should be "Does Not Need View Only" or "Needs View Only". I have been able to accomplish this via a calculated javascript (below for reference).

 

However; my issue is when I make my selection in D2 and I click away from the dropdown box it automatically defaults to the top of the list (i.e. If I select "Needs View Only" in the drop down and click away it will jump back up to "Does Not Need View Only"). I am pretty sure it is an issue with one of the properties of the dropdown but cannot figure out which one. I have played around with the Sort items and Commit after selected flag on the options tab of the properties with no help. If needed I can send screenshots of my current configuration of the dropdown properties. Any help would be greatly appreciated!!

 

Javascript : 

if (event.value=="View Only") this.getField("D2").setItems(["Does Not Need View Only", "Needs View Only"]);

This topic has been closed for replies.
Correct answer try67

Move it to the Validation event. That way it will only execute when you make a selection in that field, not in any field.

2 replies

try67
Community Expert
Community Expert
September 23, 2020

The calculation scripts overrides your selection. You can't have it both ways.

Omar5CBFAuthor
Participant
September 23, 2020

Are there any other ideas for how I could perform what I am trying to get done. Essentially what I am doing is trying to implement some sort of dynamic filtering. In reality D1 has several options to choose from in addition to View Only and I want D2 to be filtered based on D1's selection so I am not delivering a huge list of options to the users. 

try67
Community Expert
Community Expert
September 23, 2020

It is posssible, if set up correctly. See my reply above about where to place the code.

Bernd Alheit
Community Expert
Community Expert
September 23, 2020

Where does you use the script?

Omar5CBFAuthor
Participant
September 23, 2020

The script is located in the Calculate tab of D1 dropdown box. It is in the Custom calculation script box.

 

 

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 23, 2020

Move it to the Validation event. That way it will only execute when you make a selection in that field, not in any field.