Syntax error: "Missing ; before statement" for simple javascript

Explorer ,
Jan 18, 2019

Copy link to clipboard

Copied

I keep getting this syntax error, "Syntax error: "Missing ; before statement 3 and 4."  Basically, I doesn't like, String Last = this.getField("Last Name");

Here is the code I have:

this.documentFileName.replace(/.pdf/,"");

String First = this.getField("First Name");

String Last = this.getField("Last Name");

String Middle = this.getField("Middle Initial");

String State = this.getField("State");

String Patient = Last + ", " + First + " " + Middle;

The goal is the code to compare the file name to the patient's name in the PDf form fields.  I haven't written the rest yet until I can get this syntax error sorted out.

Any help would be appreciated!

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Remove the String keywords.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

523

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

Syntax error: "Missing ; before statement" for simple javascript

Explorer ,
Jan 18, 2019

Copy link to clipboard

Copied

I keep getting this syntax error, "Syntax error: "Missing ; before statement 3 and 4."  Basically, I doesn't like, String Last = this.getField("Last Name");

Here is the code I have:

this.documentFileName.replace(/.pdf/,"");

String First = this.getField("First Name");

String Last = this.getField("Last Name");

String Middle = this.getField("Middle Initial");

String State = this.getField("State");

String Patient = Last + ", " + First + " " + Middle;

The goal is the code to compare the file name to the patient's name in the PDf form fields.  I haven't written the rest yet until I can get this syntax error sorted out.

Any help would be appreciated!

Adobe Community Professional
Correct answer by Bernd Alheit | Adobe Community Professional

Remove the String keywords.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

524

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
Jan 18, 2019 0
Adobe Community Professional ,
Jan 18, 2019

Copy link to clipboard

Copied

Remove the String keywords.

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...
Jan 18, 2019 2
Explorer ,
Jan 18, 2019

Copy link to clipboard

Copied

Thank you, I changed the "String" to "var" and now it works perfectly.  Thank you!

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...
Jan 18, 2019 0
Most Valuable Participant ,
Jan 18, 2019

Copy link to clipboard

Copied

"String" is found in Java, where it is needed. It's a very natural thing to do to write JavaScript as Java Script or assume Java is short for JavaScript. Unfortunately, if you feed this into Google, you're going to get examples of how to write Java, which is not at all useful to you...

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...
Jan 18, 2019 1