Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JavaScript Syntax Error

New Here ,
Sep 05, 2023 Sep 05, 2023

I'm just trying to create a mailDoc on Mouse Up for a submit button and I'm encountering a syntax error:

var sendForm = app.alert("Are you ready to submit to " + ProgramManager + "?",2,2,"Program Manager Submission");

if(sendForm) == 4) {
this.mailDoc({bUI:true,cTo:ProgramManagerEmail,cSubject:"Incident Report Submitted",cMsg:"A new Incident Report has been submitted.\n Please sign it and return it to the sender."});
}
else
app.alert("Please continue with the form");

 

I'm getting syntax error 3: at line 4. I'm hitting a wall, so I'm open to suggestions. ProgramManagerEmail is a variable that is set from a drop-down to select a user. That populates an email address in ProgramManagerEmail.

 

Thank you,

~ David

TOPICS
Acrobat SDK and JavaScript
1.3K
Translate
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

Community Expert , Sep 05, 2023 Sep 05, 2023

The parentheses on the "if" are not correct.

Should be this:

if(sendForm == 4) {

 

 

Translate
Community Expert ,
Sep 05, 2023 Sep 05, 2023

The parentheses on the "if" are not correct.

Should be this:

if(sendForm == 4) {

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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 ,
Sep 05, 2023 Sep 05, 2023
Ugh, kept looking below not thinking about the if line.

Thanks so much!!!
Translate
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
Community Expert ,
Sep 05, 2023 Sep 05, 2023

Many syntax errors (related to delimiters) are reported on the lines following the source of the error, because it's not apparent there is an error until a non-matching token is encountered. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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 ,
Dec 14, 2023 Dec 14, 2023

Hi Thom, I am having a similar issue 

Here is the error code

syntax error 3: at line 4

 

Copy of script:

var dropdownValue = this.getField("Dropdown1").value;

case "10012253":
this.getField("Text2").value = "$50.00"
this.getField("Text3").value = "$67.00"
break;

Translate
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
Community Expert ,
Dec 14, 2023 Dec 14, 2023
LATEST

You miss the switch. 

Translate
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