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

Dependent Dropdown Script

New Here ,
Jan 18, 2023 Jan 18, 2023

I am attempting to create a pdf form with a dependent dropdown. The first column is numbers 1-60, when 1 is chosen I would like the second column to let me choose between several different code numbers.

 

I did not include my full code because I'm getting an error stating: SyntaxError: invalid switch statement 6: at line 7

 

Any help would be greatly appreciated.

 

var f = this.getField("Violation Number");

switch(event.value)

{

 

Case “1”:

f.setitems(["-Select Violation-",

“2-101.11 Assignment”,

“2-102.11(A), B) and (C)(1), (4)-(16) Demonstration”,

"2-103.11 (A)-(P) Person-In-Charge-Duties"]);

break;

 

default:

f.clearItems();

break;

}

TOPICS
PDF forms
1.8K
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 ,
Jan 18, 2023 Jan 18, 2023

Looks like the double quotes are the wrong character, i.e., a Unicode double quote. Only ASCII characters are allowed in the JavaScript Core syntax.  The issue was probably caused by entering or copying coded from a word processor app.

Use only plain text editors with JavaScript. 

 

 

 

 

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 ,
Jan 27, 2023 Jan 27, 2023

Once the double quote is removed, it still has a Syntax error stating:

invalid switch statement 5: at line 6

 

var f=this.getfield('Violation Number');

switch(event.value)

{

 

Case '1':

f.setitems(['-Select Violation-',

'2-101.11 Assignment',

'2-102.11(A), B) and (C)(1), (4)-(16) Demonstration',

'2-103.11 (A)-(P) Person-In-Charge-Duties']);

break;

 

default:

f.clearItems();

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 ,
Jan 27, 2023 Jan 27, 2023

The word "Case" is lower case.  You should check the Core JavaScript reference for these types of things. 

 

 

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 ,
Feb 17, 2023 Feb 17, 2023

Is there a person available I could email my pdf to?

 

I have all the code in with no errors, however when I return to the document it isn't working.

 

 

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 ,
Feb 17, 2023 Feb 17, 2023

You can attach your file to your post, if you wish to keep your file private send me a message, and I will share my email.

Also, you need to use setItems not setitems.

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 ,
Feb 17, 2023 Feb 17, 2023
LATEST

It's also getField, not getfield... You have to be very careful with how you spell things in JS. It's case-sensitive.

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