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

Javascript Tooltip clearing issue

Guest
Mar 15, 2016 Mar 15, 2016

I have using the script below to clear a massive amount of tool tips and am getting a syntax error from the javascript debugger. Can someone let me know possibly why I am encountering this? I can't seem to get it to work on a test PDF with simply name fields as well. I know I gotten this to work before.

// Set all field tooltips to blank
for (var i = 0; i < numFields; i++) {
getField(getNthFieldName(i)).userName = "";
}

SyntaxError: syntax error

1:Console:Exec

undefined

Thank you

TOPICS
Acrobat SDK and JavaScript , Windows
1.3K
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 ,
Mar 15, 2016 Mar 15, 2016

Works fine for me. Are you sure you're selecting the whole code when you're executing it?

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
Guest
Mar 15, 2016 Mar 15, 2016

Well I pasted the script above exactly so if that's what you validated, I am not sure why it doesn't work for me.

I merely place it in it in the javascript debugger > script and console

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 ,
Mar 15, 2016 Mar 15, 2016

To execute more than one line in the JavaScript console, you have to select all of it. Take a look here for more information about how to use the console: https://acrobatusers.com/tutorials/javascript_console

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
Guest
Mar 15, 2016 Mar 15, 2016

I did read this page and will go over it again in detail, but when you reference "you have to select it all", what is it you are referring to?

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
LEGEND ,
Mar 15, 2016 Mar 15, 2016

You have to select all of the code in the JavaScript console before you press Ctrl+Enter

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
Guest
Mar 15, 2016 Mar 15, 2016

I did attempt this as well a few times, but during the process of selecting it all in the console (highlighted blue), I am unable to hit enter (keypad) if I do this.

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 ,
Mar 15, 2016 Mar 15, 2016

Are you on a Mac? If so, things are a bit more complicated: Select the text and then use Opt-Cmd-Enter to execute it.

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
Guest
Mar 15, 2016 Mar 15, 2016

I am on Windows 7.

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
LEGEND ,
Mar 15, 2016 Mar 15, 2016

What happens if you create a button and place the code in the Mouse up event, and then click the button?

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
Guest
Mar 15, 2016 Mar 15, 2016

That worked. Does it matter what the field names are? This massive field attempting tooltip clearing (over 700 fields) have field names that consist of possible special characters.

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 ,
Mar 15, 2016 Mar 15, 2016

No. Using this method the field names shouldn't matter.

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
LEGEND ,
Mar 15, 2016 Mar 15, 2016

It is a good practice to include the "object" of the property or method you are trying to access or modify. All the properties and methods you are trying to use refer to the current opened and focused PDF, so I would add the "this." for the object;

Have you tried to add any debugging statements to print out the item being processed?

// Set all field tooltips to blank
console.show();console.clear();
console.println("number of fields: " + this.numFields);
for (var i = 0; i < numFields; i++) {
console.println(i + ": " + this.getNthFieldName(i) + " " + this.getField(this.getNthFieldName(i)).userName);
getField(getNthFieldName(i)).userName = "";
}

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
Guest
Mar 15, 2016 Mar 15, 2016

I did try the script provided with the same error.

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
Guest
Mar 15, 2016 Mar 15, 2016
LATEST

I ended up uninstalling acrobat to make sure it is now any settings/preferences that could trigger this hiccup, did that and redid the script and it worked. Thank you to everybody

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