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

Var is undefined?

New Here ,
Apr 06, 2023 Apr 06, 2023

As recently as three days ago I used this code to extract fields from a dropdown: 

var oFld = this.getField("MyField-01");

for(var i=0;i<oFld.numItems;i++) {

  console.println(oFld.getItemAt(i,true));

}

Now whenever I run it I get the following error:

SyntaxError: syntax error
1:Console:Exec
undefined

 I've triple checked that the field value name is correct, and the dropdown has over 150 values. I have no idea what the issue is. Does anyone have any idea?

TOPICS
General troubleshooting , How to , Install update and subscribe to Acrobat , JavaScript , PDF forms , Standards and accessibility
719
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 ,
Apr 06, 2023 Apr 06, 2023

Where do you use script?

Can you share file?

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
LEGEND ,
Apr 06, 2023 Apr 06, 2023
LATEST

You are not the first to be confused by the word "undefined". This is not an error, or even a warning. It is telling you the last value from the last line executed. Most working code will end up saying "undefined" or a number.

The key here is the first line, syntax error. A syntax error is something specific - something it cannot understand. It is not a mis-spelled variable name, but something like a forgotten semi-colon.

I suspect that this is not the exact code you ran, and there is a typing or copy/paste issue. Please show a screen shot of the actual code in Acrobat.

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