Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
The word "Case" is lower case. You should check the Core JavaScript reference for these types of things.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It's also getField, not getfield... You have to be very careful with how you spell things in JS. It's case-sensitive.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more