How to trigger script when value in dropbox is chosen

Jul 26, 2017

Copy link to clipboard

Copied

Hello,

I'm using Acrobat Reader DC,

I've the dropdown list ("dropdown1") with 3 options, for each option I did some coding, for example for option "system support"

if (this.getField("Dropdown1").value == "System Support") {app.alert("WELCOME KIT\n" + "Essential support agreement information",4, 0, "System Support");}

It works, BUT when I choose in dropdown list "system support" the code is triggered AFTER I click anywhere in the pdf (it's not done with the click and I need it to be excecuted when I choose that "System support" option).

In options of the dropdown list I've selected "commit selected value immidieatly" but I'm missing something...I tried some ideas in the internet like:

if(event.willCommit)
{
  
switch(event.value)
  
{
  
case "System Support":
    {app.alert("WELCOME KIT\n" + "Essential support agreement information",4, 0, "System Support");}
;
  
break;

I believe I'm doing something wrong. Could you please help me?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Delete all other actions you added. Just use this one, as the custom validation script.

If it still doesn't work, share the file (via Dropbox, Google Drive, Adobe Cloud, etc.).

TOPICS
Acrobat SDK and JavaScript

Views

223

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

How to trigger script when value in dropbox is chosen

Jul 26, 2017

Copy link to clipboard

Copied

Hello,

I'm using Acrobat Reader DC,

I've the dropdown list ("dropdown1") with 3 options, for each option I did some coding, for example for option "system support"

if (this.getField("Dropdown1").value == "System Support") {app.alert("WELCOME KIT\n" + "Essential support agreement information",4, 0, "System Support");}

It works, BUT when I choose in dropdown list "system support" the code is triggered AFTER I click anywhere in the pdf (it's not done with the click and I need it to be excecuted when I choose that "System support" option).

In options of the dropdown list I've selected "commit selected value immidieatly" but I'm missing something...I tried some ideas in the internet like:

if(event.willCommit)
{
  
switch(event.value)
  
{
  
case "System Support":
    {app.alert("WELCOME KIT\n" + "Essential support agreement information",4, 0, "System Support");}
;
  
break;

I believe I'm doing something wrong. Could you please help me?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Delete all other actions you added. Just use this one, as the custom validation script.

If it still doesn't work, share the file (via Dropbox, Google Drive, Adobe Cloud, etc.).

TOPICS
Acrobat SDK and JavaScript

Views

224

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
Jul 26, 2017 0
Most Valuable Participant ,
Jul 26, 2017

Copy link to clipboard

Copied

Use the Validation script and replace this part of your code:

this.getField("Dropdown1").value

With:

event.value

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...
Jul 26, 2017 0
Jul 26, 2017

Copy link to clipboard

Copied

Hey,

I just tried:

if (event.value == "System Support") {app.alert("WELCOME KIT\n" + "Essential support agreement information",4, 0, "System Support");}

It's still working the same. I should also mention that in actions of that dropdown list, I've selected trigger "on blur", mainly because mouse up/down/enter/exit and on focus is not working with the dropdown list correctly.

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...
Jul 26, 2017 0
Most Valuable Participant ,
Jul 26, 2017

Copy link to clipboard

Copied

Delete all other actions you added. Just use this one, as the custom validation script.

If it still doesn't work, share the file (via Dropbox, Google Drive, Adobe Cloud, etc.).

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...
Jul 26, 2017 0
Jul 26, 2017

Copy link to clipboard

Copied

It works!

Thank you

So the problem was that I didn't put my code in custom validation script but within action !

Thanks a lot !

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...
Jul 26, 2017 0