Highlighted

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

New Here ,
Sep 23, 2020

Copy link to clipboard

Copied

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"]);

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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

TOPICS
Acrobat SDK and JavaScript, General troubleshooting, PDF forms

Views

105

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

New Here ,
Sep 23, 2020

Copy link to clipboard

Copied

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"]);

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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

TOPICS
Acrobat SDK and JavaScript, General troubleshooting, PDF forms

Views

106

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 23, 2020 0
Adobe Community Professional ,
Sep 23, 2020

Copy link to clipboard

Copied

Where does you use the script?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 23, 2020 0
New Here ,
Sep 23, 2020

Copy link to clipboard

Copied

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

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 23, 2020 0
Most Valuable Participant ,
Sep 23, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 23, 2020 0
New Here ,
Sep 23, 2020

Copy link to clipboard

Copied

That did it!! Thank you so much for your help try67, I actually stole my javascript code from an earlier post of yours so you have helped me twice on this issue!! 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 23, 2020 0
Most Valuable Participant ,
Sep 23, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 23, 2020 0
New Here ,
Sep 23, 2020

Copy link to clipboard

Copied

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. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 23, 2020 0
try67 LATEST
Most Valuable Participant ,
Sep 23, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 23, 2020 0