2

I have a PDF document that is essentially a form which gets emailed. I'm trying to add functionality to a button. I want that button to run a Javascript which would fill in the formfield "Notes" with predetermined text and with the value of certain form fields.

ie, I click the button and it adds the following to formfield "Notes": "Blah blah blah (contents of formfield called "name"). Blah blah. etc..."

I want the form and that field to still be editable and not flattened at that point.

It seems so simple but I can't find anything on it?

If I could accomplish that, I also would like it to insert more detailed text:

  • If FormField "A" is Yes, insert text to formfield notes "blah blah blah"
  • If FormField "A" is No, insert text to formfield notes "yada yada yah"

Update

  • All end users are utilizing Adobe Acrobat Pro DC.
  • Since posting I was able to get it to insert text, now I just want to get it to insert text conditionally. If A is yes, then insert X. If A is no, then insert Y, etc... But I have no idea how to do that.

this.getField("Agriculture Operation Notes").value = "Permission to conduct the On-Site Supercheck was granted by the proposed insured, " + this.getField("First Name").value + " " + this.getField("Last Name").value + ", on a " + this.getField("Inspection Type").value + " basis. \n\n\It was so cold outside. \n\n\This is just a demonstration of how we can use JavaScript to improve our reports.\n\n\";
minnesota73
  • 33
  • 1
  • 6
  • What have you tried so far? Please edit your question and snippet your code. – habib Nov 19 '19 at 17:52
  • You can add JavaScript to accomplish this but it will only run in a few of the current PDF viewers. What environments do you need this to work in? – joelgeraci Nov 19 '19 at 19:45
  • Habib and joelgeraci thanks for your responses. - All end users utilize Adobe Acrobat Pro DC to get JavaScript to work - I'll edit my original post to include code – minnesota73 Nov 19 '19 at 20:00

1 Answers1

0

I was able to get this to work:

this.getField("Field To Fill").value = ""+PARA_INTRO+" \n\n"+PARA_OPERATION+"";

Then I'm using switch functions to set variable like PARA_INTRO based on the values of other variables.

minnesota73
  • 33
  • 1
  • 6