Skip to main content
Participating Frequently
October 22, 2024
解決済み

Help with Javascript code for paragraph generation

  • October 22, 2024
  • 返信数 2.
  • 1543 ビュー

Hello all, desperately need help. I've created a dynamic PDF document with input fields and a paragraph box with some javascript code. I can get smaller code to work but no matter what I do when I put in the bigger code I get issues. Can anyone look it over and see what I'm doing wrong between the "Paragraph1" box (Text Field Properties > Validate tab > Run custom validation script: code) and the "Upload Form" buttons (Button Properties > Actions > Mouse Up = Run a Javascript code)? I've been working on this for awhile and amd just frustrated and discouraged. Thanks in advance. 

このトピックへの返信は締め切られました。
解決に役立った回答 PDF Automation Station

It looks like a lot of your field names in the script use curly quotes instead of straight quotes.  You should use a plain text editor like Notepad to write your scripts.

返信数 2

Participating Frequently
October 22, 2024

I noticed I was missing a quote in the last line of code. However, it still is only replacing the "CompanyName" input field value and none of the others. So I must be missing something. 

PDF Automation Station
Community Expert
Community Expert
October 22, 2024

In the last line, you have curly quotes encasing the field name.  You also need to encase your curly quotes in regular quotes like this:

"“" + this.getField("SignatureOption").value + "”";

PDF Automation Station
Community Expert
Community Expert
October 22, 2024

It looks like a lot of your field names in the script use curly quotes instead of straight quotes.  You should use a plain text editor like Notepad to write your scripts.

Participating Frequently
October 22, 2024

Forgot to explain that the code is meant to auto-generate a paragraph in the "Paragraph1" box and insert key text from some of the input fields above it. But it doesn't work when I have the full thing in there, only when I do a smaller chunk of code. 

PDF Automation Station
Community Expert
Community Expert
October 22, 2024

Validation scripts only run when the value of the field (Paragraph1 in this case) changes so it will never run until something is keyed in to the Paragraph1 field.  This script should be moved from a validation script to a calculation script:

https://pdfautomationstation.substack.com/p/calculation-vs-validation-scripts

https://pdfautomationstation.substack.com/p/calculation-vs-validation-scripts-eb5

 

Participating Frequently
October 22, 2024

Did you see the second document I posted. It runs without putting anything in "Paragraph1". I left out a " towards the end of the javascript. I also moved it to a calculation script and it seems to work exactly the same. I still can't figure out why only the first input field populates throughout the paragraph but none of the other input fields do. Am I typing the javascript code wrong or something?