Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy field values in Acrobat using Javascript

How can I copy the form field values from one set of fields to another using javascript.

The idea here is to have a 'use shipping/billing address' type of button that copies the user information from one block of fields to another identical set of fields.

Right now, I call an action upon click of a button to execute the following javascript:

this.field1.value = this.field2.value;

However that action yields an 'undefined' error in the debugger.

like image 499
CaseyHunt Avatar asked Nov 08 '11 19:11

CaseyHunt


People also ask

How to copy data from one field to another using JavaScript?

The JavaScript itself is used to grab the data that has been entered into one form field, and when the checkbox is selected (checked), it copies that data to another field in the form. The form looks like this: Check this box if Billing Address and Mailing Address are the same. The JavaScript used to achieve the effect looks like this:

How to create a form field using JavaScript in Acrobat DC?

Acrobat JS Developer Guide Creating Acrobat DC form fields 65 You can use JavaScript to create a form field by invoking the addField method of the Doc object, which returns a Field object. This method permits you to specify the following information: The field name.

What can I do with the JavaScript for Acrobat API?

With it, for example, you can create a document that reports back a list of all form fields in the document, along with their types and values; another application is to summarize all comments in a document. The JavaScript for Acrobat API Reference has an example of the latter application in the Report object section.

How do I lock form fields in Acrobat JS?

Acrobat JS Developer Guide Digitally signing PDF documents 153 Secure forms You can lock form fields by creating a script containing a call to the Field object setLock method, and passing that script as the second parameter to the signature field setAction method.


1 Answers

For posterity, this is the solution to the problem:

getField("field2").value = getField("field1").valueAsString;

Also, note that field2 is set to field1 so the order is backwards.

like image 157
CaseyHunt Avatar answered Sep 23 '22 04:09

CaseyHunt