Skip to main content
benadamsphoto
Known Participant
January 8, 2018
Answered

Help with script for Pop-Up Message - Acrobat Form

  • January 8, 2018
  • 1 reply
  • 1050 views

Hi All - first post here on the Adobe forums, hopefully someone cleverer than I can help!

I’m designing a PDF form for electronic completion.

The client needs a pop up message to appear if particular choices are made from two drop-down menu fields, for arguments sake lets call them Field1 and Field2.

I‘ve nearly manged to get this working nicely using a run JAVA script action upon exit/blur from Field2, however I only know how to trigger the pop-up message based on the entry value of Field2 - see an example of the code I have running now below;

if (getField"Field2").value=="1")  app.alert({ cMsg: "Dialogue message here", cTitle: "Message Window Title Here", nIcon: 3,  nType: 0 });

However, I don’t know how to write the script to include the condition of Field1, effectively saying ‘if (getField"Field1").value=="1") AND if (getField"Field2").value=="1") THEN run the app alert’ - if that makes sense!

Is anyone able to help?

Many thanks in advance!

This topic has been closed for replies.
Correct answer Bernd Alheit

Use this:

if (this.getField("Field2").value=="1" && this.getField("Field1").value=="1")  ...

1 reply

try67
Community Expert
Community Expert
January 8, 2018

Exactly like that, only by using the correct AND logical operator, which in JS is "&&", so:

if (this.getField"Field2").value=="1" && this.getField"Field1").value=="1")  ...

benadamsphoto
Known Participant
January 8, 2018

try67 - thank you for your assistance. I'm an absolute novice when it comes to JS, but I did some research and did think '&&' must be part of the solution but couldn't get it to work!

Based on your advice, I've just tried the following:

if (this.getField"Field1").value=="1" && this.getField"Field2").value=="1") app.alert({cMsg: "Pop-up Message Here", cTitle: "Window Title Here", nIcon: 3, nType: 0});

However I cannot commit the script - I'm getting "SyntaxError: missing ) after condition 1: at line 2" - any  ideas?

Thanks again

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
January 8, 2018

Use this:

if (this.getField("Field2").value=="1" && this.getField("Field1").value=="1")  ...