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

What JavaScript would I use to add the file name to a Text Field form?

New Here ,
Aug 16, 2016 Aug 16, 2016

Without being a JavaScript novice, it there a JavaScript that I can cut and past that would automatically add the file name to a Text Field in the form when the form is opened?

Thanks Much.

TOPICS
Acrobat SDK and JavaScript , Windows
968
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

correct answers 1 Correct answer

Community Expert , Aug 16, 2016 Aug 16, 2016

Yes, this code:

this.getField("Name of field").value = this.documentFileName;

Translate
Community Expert ,
Aug 16, 2016 Aug 16, 2016

Yes, this code:

this.getField("Name of field").value = this.documentFileName;

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
New Here ,
Aug 17, 2016 Aug 17, 2016

Thank you very much.  Is there a way to have it automatically update without having to click on the text box once the file is opened?

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 ,
Aug 17, 2016 Aug 17, 2016

You need to place the code as a doc-level field and then it will execute each time the file is opened.

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 ,
Aug 17, 2016 Aug 17, 2016

If you mean that you want it to update after you save the file under a new name, then you can also put it under the document's Did Save action.

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
New Here ,
Aug 17, 2016 Aug 17, 2016

How do you 'place the code as a doc-level field'?

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 ,
Aug 17, 2016 Aug 17, 2016

Go to Tools - JavaScript - Document JavaScripts and insert it there under a new item called "scripts" (for example).

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
New Here ,
Aug 17, 2016 Aug 17, 2016

Sorry if I'm driving you crazy but. I'm in an Adobe Acrobat Pro form.  I'm entering the JavaScript in the text field 'Properties' 'Actions'.  I can't find a Tools - JavaScript - Document JavaScripts anywhere in Adobe.

The text field will populate but only if I click on it manually after I open the form.

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 ,
Aug 17, 2016 Aug 17, 2016

Don't put the code there. Put it where I specified... Do you see the Tools button in the application? If so, click it and continue from there.

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
New Here ,
Aug 17, 2016 Aug 17, 2016
LATEST

Found it.  Thanks a bunch!

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