SyntaxError Help Please!

Community Beginner ,
May 29, 2018

Copy link to clipboard

Copied

I am using Adobe XI Pro with Windows 10

I am attempting to use Javascript to allaow users to select from location list with 10 options and then use JavaScript to limit the selction options using the below script.

I added the below script to the Validation JavaScript Editor and got a SyntaxError: missing ] after element list 11: at line 12

Help Please!

Thanks for the help

switch (event.value) {

    case "- Select One -":

        this.getField("G/L Account").setItems(["-----"]);

        break;

    case "Corpus Christi":

        this.getField("G/L Account").setItems(["- Select One "22289 CC ACCOUNTING G/A 1034","22340 CC AQUATICS FITNESS G/A 1034","22341 CC AQUATICS FITNESS OTH F&B 1034","22342 CC AQUATICS FITNESS PROGRAM 1034","22343 CC AQUATICS FITNESS UFM 1034","22318 CC AUTO SKILLS G/A 1034","22320 CC AUTO SKILLS PROGRAM 1034","22319 CC AUTO SKILLS RESALE 1034","22321 CC AUTO SKILLS UFM 1034","21679 CC BOWLING AMUSEMENT 1034","22353 CC BOWLING BAR 1034","21638 CC BOWLING FOOD 1034","22352 CC BOWLING G/A 1034","22352 CC BOWLING G/A 1034","22355 CC BOWLING OTH F&B 1034","22356 CC BOWLING PROGRAM 1034","21678 CC BOWLING RENTAL 1034","22354 CC BOWLING RESALE 1034","22357 CC BOWLING UFM 1034","23970 CC CAMPSITES CAT C G/A 1034","23970 CC CAMPSITES CAT C G/A 1034","23971 CC CAMPSITES CAT C PROGRAM 1034","22298 CC CATALINA CLUB BAR 1034","22297 CC CATALINA CLUB FOOD 1034","22296 CC CATALINA CLUB G/A 1034","22360 CC CDC G/A 1034","22361 CC CDC PROGRAM 1034","22362 CC CDC UFM 1034","22363 CC CDH G/A 1034","22364 CC CDH PROGRAM 1034","22365 CC CDH UFM 1034","22295 CC CIVILIAN FUND G/A 1034","22302 CC COFFEE SHOP G/A 1034","22303 CC COFFEE SHOP OTH F&B 1034","22303 CC COFFEE SHOP OTH F&B 1034","22287 CC DIRECTOR G/A 1034","22288 CC DIRECTOR UFM 1034","22344 CC FITNESS CENTER G/A 1034","22345 CC FITNESS CENTER OTH F&B 1034","22346 CC FITNESS CENTER PROGRAM 1034","22347 CC FITNESS CENTER UFM 1034","22347 CC FITNESS CENTER UFM 1034","23451 CC FITNESS CONDITIONING G/A 1034","23452 CC FITNESS CONDITIONING PROGRAM 1034","23453 CC FITNESS CONDITIONING UFM 1034","22301 CC FLIGHT DECK BAR 1034","22300 CC FLIGHT DECK FOOD 1034","22299 CC FLIGHT DECK G/A 1034"]);

                                                                           This is where I get the error SyntaxError: missing ] after element list 11: at line 12

        break;

    case "Cape Canaveral":

        this.getField("G/L Account").setItems([“- Select One -”, "22262 CAPE ACCOUNTING G/A 1034","22274 CAPE DEPLOYED FORCES G/A 1034","22275 CAPE DEPLOYED FORCES PROGRAM 1034","22276 CAPE DEPLOYED FORCES UFM 1034","22260 CAPE DIRECTOR G/A 1034","22261 CAPE DIRECTOR UFM 1034","21582 CAPE FITNESS G/A 1034","21643 CAPE FITNESS PROG 1034","21583 CAPE FITNESS UFM 1034","22258 CAPE GENERAL FUND G/A 1034","22259 CAPE GENERAL FUND UFM 1034","22268 CAPE GREEN HOUSE BAR 1034","22267 CAPE GREEN HOUSE FOOD 1034","22266 CAPE GREEN HOUSE G/A 1034","22269 CAPE GREEN HOUSE RESALE 1034","22264 CAPE MARKETING G/A 1034","22265 CAPE MARKETING UFM 1034","22263 CAPE PERSONNEL G/A 1034"]);

        break;

    case "Jacksonville":

        this.getField("G/L Account").setItems(["- Select One -", "22289 CC ACCOUNTING G/A 1034","22340 CC AQUATICS FITNESS G/A 1034","22341 CC AQUATICS FITNESS OTH F&B 1034","22342 CC AQUATICS FITNESS PROGRAM 1034","22343 CC AQUATICS FITNESS UFM 1034","22318 CC AUTO SKILLS G/A 1034","22320 CC AUTO SKILLS PROGRAM 1034","22319 CC AUTO SKILLS RESALE 1034","22321 CC AUTO SKILLS UFM 1034","21679 CC BOWLING AMUSEMENT 1034","22353 CC BOWLING BAR 1034","21638 CC BOWLING FOOD 1034","22352 CC BOWLING G/A 1034","22352 CC BOWLING G/A 1034","22355 CC BOWLING OTH F&B 1034","22356 CC BOWLING PROGRAM 1034","21678 CC BOWLING RENTAL 1034","22354 CC BOWLING RESALE 1034","22357 CC BOWLING UFM 1034","23970 CC CAMPSITES CAT C G/A 1034","23970 CC CAMPSITES CAT C G/A 1034","23971 CC CAMPSITES CAT C PROGRAM 1034","22298 CC CATALINA CLUB BAR 1034","22297 CC CATALINA CLUB FOOD 1034","22296 CC CATALINA CLUB G/A 1034","22360 CC CDC G/A 1034","22361 CC CDC PROGRAM 1034","22362 CC CDC UFM 1034","22363 CC CDH G/A 1034","22364 CC CDH PROGRAM 1034","22365 CC CDH UFM 1034","22295 CC CIVILIAN FUND G/A 1034","22302 CC COFFEE SHOP G/A 1034","22303 CC COFFEE SHOP OTH F&B 1034","22303 CC COFFEE SHOP OTH F&B 1034","22287 CC DIRECTOR G/A 1034","22288 CC DIRECTOR UFM 1034","22344 CC FITNESS CENTER G/A 1034","22345 CC FITNESS CENTER OTH F&B 1034","22346 CC FITNESS CENTER PROGRAM 1034","22347 CC FITNESS CENTER UFM 1034","22347 CC FITNESS CENTER UFM 1034","23451 CC FITNESS CONDITIONING G/A 1034","23452 CC FITNESS CONDITIONING PROGRAM 1034","23453 CC FITNESS CONDITIONING UFM 1034","22301 CC FLIGHT DECK BAR 1034","22300 CC FLIGHT DECK FOOD 1034","22299 CC FLIGHT DECK G/A 1034"]);

        break;

}

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Word and Excel are not plain-text or code editors. You should not use them to write code.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

132

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

SyntaxError Help Please!

Community Beginner ,
May 29, 2018

Copy link to clipboard

Copied

I am using Adobe XI Pro with Windows 10

I am attempting to use Javascript to allaow users to select from location list with 10 options and then use JavaScript to limit the selction options using the below script.

I added the below script to the Validation JavaScript Editor and got a SyntaxError: missing ] after element list 11: at line 12

Help Please!

Thanks for the help

switch (event.value) {

    case "- Select One -":

        this.getField("G/L Account").setItems(["-----"]);

        break;

    case "Corpus Christi":

        this.getField("G/L Account").setItems(["- Select One "22289 CC ACCOUNTING G/A 1034","22340 CC AQUATICS FITNESS G/A 1034","22341 CC AQUATICS FITNESS OTH F&B 1034","22342 CC AQUATICS FITNESS PROGRAM 1034","22343 CC AQUATICS FITNESS UFM 1034","22318 CC AUTO SKILLS G/A 1034","22320 CC AUTO SKILLS PROGRAM 1034","22319 CC AUTO SKILLS RESALE 1034","22321 CC AUTO SKILLS UFM 1034","21679 CC BOWLING AMUSEMENT 1034","22353 CC BOWLING BAR 1034","21638 CC BOWLING FOOD 1034","22352 CC BOWLING G/A 1034","22352 CC BOWLING G/A 1034","22355 CC BOWLING OTH F&B 1034","22356 CC BOWLING PROGRAM 1034","21678 CC BOWLING RENTAL 1034","22354 CC BOWLING RESALE 1034","22357 CC BOWLING UFM 1034","23970 CC CAMPSITES CAT C G/A 1034","23970 CC CAMPSITES CAT C G/A 1034","23971 CC CAMPSITES CAT C PROGRAM 1034","22298 CC CATALINA CLUB BAR 1034","22297 CC CATALINA CLUB FOOD 1034","22296 CC CATALINA CLUB G/A 1034","22360 CC CDC G/A 1034","22361 CC CDC PROGRAM 1034","22362 CC CDC UFM 1034","22363 CC CDH G/A 1034","22364 CC CDH PROGRAM 1034","22365 CC CDH UFM 1034","22295 CC CIVILIAN FUND G/A 1034","22302 CC COFFEE SHOP G/A 1034","22303 CC COFFEE SHOP OTH F&B 1034","22303 CC COFFEE SHOP OTH F&B 1034","22287 CC DIRECTOR G/A 1034","22288 CC DIRECTOR UFM 1034","22344 CC FITNESS CENTER G/A 1034","22345 CC FITNESS CENTER OTH F&B 1034","22346 CC FITNESS CENTER PROGRAM 1034","22347 CC FITNESS CENTER UFM 1034","22347 CC FITNESS CENTER UFM 1034","23451 CC FITNESS CONDITIONING G/A 1034","23452 CC FITNESS CONDITIONING PROGRAM 1034","23453 CC FITNESS CONDITIONING UFM 1034","22301 CC FLIGHT DECK BAR 1034","22300 CC FLIGHT DECK FOOD 1034","22299 CC FLIGHT DECK G/A 1034"]);

                                                                           This is where I get the error SyntaxError: missing ] after element list 11: at line 12

        break;

    case "Cape Canaveral":

        this.getField("G/L Account").setItems([“- Select One -”, "22262 CAPE ACCOUNTING G/A 1034","22274 CAPE DEPLOYED FORCES G/A 1034","22275 CAPE DEPLOYED FORCES PROGRAM 1034","22276 CAPE DEPLOYED FORCES UFM 1034","22260 CAPE DIRECTOR G/A 1034","22261 CAPE DIRECTOR UFM 1034","21582 CAPE FITNESS G/A 1034","21643 CAPE FITNESS PROG 1034","21583 CAPE FITNESS UFM 1034","22258 CAPE GENERAL FUND G/A 1034","22259 CAPE GENERAL FUND UFM 1034","22268 CAPE GREEN HOUSE BAR 1034","22267 CAPE GREEN HOUSE FOOD 1034","22266 CAPE GREEN HOUSE G/A 1034","22269 CAPE GREEN HOUSE RESALE 1034","22264 CAPE MARKETING G/A 1034","22265 CAPE MARKETING UFM 1034","22263 CAPE PERSONNEL G/A 1034"]);

        break;

    case "Jacksonville":

        this.getField("G/L Account").setItems(["- Select One -", "22289 CC ACCOUNTING G/A 1034","22340 CC AQUATICS FITNESS G/A 1034","22341 CC AQUATICS FITNESS OTH F&B 1034","22342 CC AQUATICS FITNESS PROGRAM 1034","22343 CC AQUATICS FITNESS UFM 1034","22318 CC AUTO SKILLS G/A 1034","22320 CC AUTO SKILLS PROGRAM 1034","22319 CC AUTO SKILLS RESALE 1034","22321 CC AUTO SKILLS UFM 1034","21679 CC BOWLING AMUSEMENT 1034","22353 CC BOWLING BAR 1034","21638 CC BOWLING FOOD 1034","22352 CC BOWLING G/A 1034","22352 CC BOWLING G/A 1034","22355 CC BOWLING OTH F&B 1034","22356 CC BOWLING PROGRAM 1034","21678 CC BOWLING RENTAL 1034","22354 CC BOWLING RESALE 1034","22357 CC BOWLING UFM 1034","23970 CC CAMPSITES CAT C G/A 1034","23970 CC CAMPSITES CAT C G/A 1034","23971 CC CAMPSITES CAT C PROGRAM 1034","22298 CC CATALINA CLUB BAR 1034","22297 CC CATALINA CLUB FOOD 1034","22296 CC CATALINA CLUB G/A 1034","22360 CC CDC G/A 1034","22361 CC CDC PROGRAM 1034","22362 CC CDC UFM 1034","22363 CC CDH G/A 1034","22364 CC CDH PROGRAM 1034","22365 CC CDH UFM 1034","22295 CC CIVILIAN FUND G/A 1034","22302 CC COFFEE SHOP G/A 1034","22303 CC COFFEE SHOP OTH F&B 1034","22303 CC COFFEE SHOP OTH F&B 1034","22287 CC DIRECTOR G/A 1034","22288 CC DIRECTOR UFM 1034","22344 CC FITNESS CENTER G/A 1034","22345 CC FITNESS CENTER OTH F&B 1034","22346 CC FITNESS CENTER PROGRAM 1034","22347 CC FITNESS CENTER UFM 1034","22347 CC FITNESS CENTER UFM 1034","23451 CC FITNESS CONDITIONING G/A 1034","23452 CC FITNESS CONDITIONING PROGRAM 1034","23453 CC FITNESS CONDITIONING UFM 1034","22301 CC FLIGHT DECK BAR 1034","22300 CC FLIGHT DECK FOOD 1034","22299 CC FLIGHT DECK G/A 1034"]);

        break;

}

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Word and Excel are not plain-text or code editors. You should not use them to write code.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

133

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 29, 2018 0
Most Valuable Participant ,
May 29, 2018

Copy link to clipboard

Copied

You can only use straight quotes to define strings, and if you want to insert a straight quote into the string itself you need to escape it.

You're also missing a closing quotes and a comma here:

["- Select One "22289 CC ACCOUNTING G/A 1034",

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0
Community Beginner ,
May 29, 2018

Copy link to clipboard

Copied

I am a novice when it come to Javascript can you please provide an example of the use of straight quote.

Thank you for all the help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0
Most Valuable Participant ,
May 29, 2018

Copy link to clipboard

Copied

You already did it in your code, just not everywhere...

This is correct:

"22262 CAPE ACCOUNTING G/A 1034"

This is incorrect:

“- Select One -”

Notice the quotes in the latter are curly, not straight.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0
Community Beginner ,
May 29, 2018

Copy link to clipboard

Copied

I made the changes and I am still getting the same error?

DECK FOOD 1034","22299 CC FLIGHT DECK G/A 1034"]);

                                                                                                         It's still saying missing ] after element list?

        break;

    case "Cape Canaveral":

        this.getField("G/L

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0
Most Valuable Participant ,
May 29, 2018

Copy link to clipboard

Copied

Tip: never use Word at any point in your editing of scripts.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0
Most Valuable Participant ,
May 29, 2018

Copy link to clipboard

Copied

Use Notepad++ and set the Language to JavaScript. It will quickly show you where things go wrong.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0
Community Beginner ,
May 29, 2018

Copy link to clipboard

Copied

I was using Word and Excel to combine text.  Do they cause problems or is the Notepad++ just able to quickly show errors?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0
Most Valuable Participant ,
May 29, 2018

Copy link to clipboard

Copied

Word and Excel are not plain-text or code editors. You should not use them to write code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0
Most Valuable Participant ,
May 29, 2018

Copy link to clipboard

Copied

Yes, they cause this exact problem, by changing your quotes. They call it "smart quotes". Unless they know exactly how to turn it off (and when to turn it back on), programmers need to avoid these apps like the plague.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2018 0