Skip to main content
Participating Frequently
May 16, 2019 5:27 PM UTC
Question

Need help with syntax error 4: at line 5

The only way this field should populate a yes answer is the first If statement. Any other combination should return a No. What am I missing?

Thanks for the help!

var A = this.getField("QualifyingPercentage").value;

var B = this.getField("CiscoSKU").value;

event.value = "";

if(A>.749000)&& B = Yes)event.value = "Yes";

else if(A>.749000)&& B = No)event.value = "No";

}

This topic is closed to new replies. Start a new post to keep the conversation going.

6 replies

Thom Parker
Community Expert
Community Expert
May 16, 2019 5:46 PM UTC

You've got three issues.

1. Yes and No are string literal values, not variable names. They need to be quoted.

2. "=" is the assignment operator. To compare values use the equivalence operator "=="

3. Brackets and parentheses come in pairs, an opening and a closing, You have missmatched items in several places.

All programming is about details. You should consider spending some time going over your script and learning a few things about JavaScript.

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participating Frequently
May 16, 2019 5:49 PM UTC

Aware my java is very rusty - which is why I reached out for help. Thank you for the suggestions.

Translate
Bernd Alheit
Community Expert
Community Expert
May 16, 2019 6:13 PM UTC

Info: It is Javascript, not Java.

Translate
try67
Community Expert
Community Expert
May 16, 2019 5:42 PM UTC

Count the number of opening and closing parentheses.

Translate
try67
Community Expert
Community Expert
May 16, 2019 5:42 PM UTC

Also, the comparison operator in JS is "==", not "=", although that's not a syntax error.

Translate