Skip to main content
carolinef572441
Participant
January 18, 2023
Question

Dependent Dropdown Script

  • January 18, 2023
  • 1 reply
  • 1741 views

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;

}

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
January 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
carolinef572441
Participant
January 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;

}

Thom Parker
Community Expert
Community Expert
January 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 PDFScriptingUse the Acrobat JavaScript Reference early and often