Help with script for Pop-Up Message - Acrobat Form

New Here ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

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!

TOPICS
Acrobat SDK and JavaScript

Views

226

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Jan 08, 2018 Jan 08, 2018
Use this:if (this.getField("Field2").value=="1" && this.getField("Field1").value=="1")  ...

Likes

Translate

Translate
Adobe Community Professional ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

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")  ...

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
community guidelines
New Here ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

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

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
community guidelines
Adobe Community Professional ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

Use this:

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

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
community guidelines
New Here ,
Jan 08, 2018 Jan 08, 2018

Copy link to clipboard

Copied

LATEST

Bernd Alheit you are a hero - perfect.

Many thanks all!

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
community guidelines