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

SyntaxError: missing ) after argument list

Participant ,
Jan 14, 2020 Jan 14, 2020

Copy link to clipboard

Copied

I'm getting the above error when I try to hit "okay" after editing a script in a field. The offending lines are:

//set properties of check box
togBot.strokeColor = color.black; togBot.fillColor = color.white;
togBot.setAction("MouseUp", "this.getField("botPh" + spwn).display = (event.target.value=="Off") ? display.hidden : display.visible");

 The parentheses match up, and the code matches a very similar (working) one elsewhere in the script. What is going wrong? Thanks!

TOPICS
Acrobat SDK and JavaScript

Views

1.6K

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
community guidelines

correct answers 2 Correct answers

LEGEND , Jan 14, 2020 Jan 14, 2020

You’re trying to use quotes in your action script. But the quotes END the string. 

"this.getField(" is the complete string and everything else is an error. How could it know you meant something different? Look up “Javascript string escapes”. 

Votes

Translate

Translate
Participant , Jan 14, 2020 Jan 14, 2020

I'd hoped the open paren would help...

 

spwn is going to be replaced... I tried it without that there anyway. 

 

A backslash before my internal quotes is what I needed. Thanks for the direction.

Votes

Translate

Translate
LEGEND ,
Jan 14, 2020 Jan 14, 2020

Copy link to clipboard

Copied

You’re trying to use quotes in your action script. But the quotes END the string. 

"this.getField(" is the complete string and everything else is an error. How could it know you meant something different? Look up “Javascript string escapes”. 

Votes

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
community guidelines
Community Expert ,
Jan 14, 2020 Jan 14, 2020

Copy link to clipboard

Copied

Where does you set spwn?

Votes

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
community guidelines
Participant ,
Jan 14, 2020 Jan 14, 2020

Copy link to clipboard

Copied

I'd hoped the open paren would help...

 

spwn is going to be replaced... I tried it without that there anyway. 

 

A backslash before my internal quotes is what I needed. Thanks for the direction.

Votes

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
community guidelines
Participant ,
Jan 14, 2020 Jan 14, 2020

Copy link to clipboard

Copied

One a related note, what's a good practice for longer, multiline codes inside my setAction method? Is there a syntax that allows me to have multiple things on their own lines within the method? I want the spawn checkbox to have the following script:

var num = event.target.name.match(/\d/g).join('');
this.getField("botPh" + num).display = (event.target.value=="Off") ? display.hidden : display.visible;

Votes

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
community guidelines
Community Expert ,
Jan 14, 2020 Jan 14, 2020

Copy link to clipboard

Copied

For large codes I use document-level functions.

Votes

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
community guidelines
Participant ,
Jan 14, 2020 Jan 14, 2020

Copy link to clipboard

Copied

LATEST

Thanks! I found this tip and another, which I'm using. I'm just creating a string (with hella regex) with the code, then passing that as the argument for setAction. I appreciate the help!

Votes

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
community guidelines