Forms: Javascript Best Practices - writing scripts for each field vs one script, i.e. hidden calc...

Explorer ,
Sep 09, 2022 Sep 09, 2022

Copy link to clipboard

Copied

Hey all, I'm still relatively new to javascript for forms in acrobat. But my forms have quickly become quite complex. I design them in Indesign with as much functionality as possible and then add java in acrobat. I have fields with onBlur and onFocus actions, validations that display or hide other fields or buttons, dropdowns coded to hide or display other fields, indesign buttons that function as error messages that hide/display when needed. 

 

The problem is: these scripts are all in separate places.  I can edit them to an extent in the All JavaScripts editor. Honestly, that editor is more confusing to me at this point--I believe, due to the XML tags. 

 

1. Is it best-practices to consolidate all scripts in one place, especially if I plan to make more complex forms?

2. Is that place the All JavaScripts editor or somewhere else?

 

Thanks for you time.

 

 

TOPICS
JavaScript , PDF forms

Views

41

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
community guidelines
Community Expert ,
Sep 10, 2022 Sep 10, 2022

Copy link to clipboard

Copied

1. Yes.

2. I use to place all my scripts as functions in a document level script, then all fields call those functions. Which greatly simplifies maintenance and correction.

See: https://www.pdfscripting.com/public/Document-Level-Scripts.cfm

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
community guidelines
Community Expert ,
Sep 10, 2022 Sep 10, 2022

Copy link to clipboard

Copied

LATEST

Do NOT use the Edit All JavaScripts command to edit your code. If something goes wrong, like an XML tag is broken, it can seriously screw up your entire file. Use the Document JavaScripts command to edit the doc-level scripts, instead.

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