Skip to main content
prop281218
Participating Frequently
July 24, 2019
Answered

Text variables with javascript?

  • July 24, 2019
  • 2 replies
  • 1701 views

Hi all,

I'm looking for an answer if something I'm proposing is possible using javascript (or something else entirely). I'm looking to create a PDF form but have 'First name' and 'Surname' fields on the cover, but within the document variable text fields that populate with the 'First name' on other pages. Is this possible, or would this not be javascript at all?

So for example:

Page 1

First name: Becky

Surname: Smith

Page 3

Running header: "<Becky>'s workbook"

Page 5

Body copy: "<Becky>, here is your chance to answer some questions."

Any advice greatly appreciated!

This topic has been closed for replies.
Correct answer try67

For that you will need to use fields with unique names and a simple script to copy the value other.

For example, if the editable field is called "Name" and the copy is called "NameCopy", use the following code as the custom calculation script of the latter:

event.value = this.getField("Name").valueAsString;

Then you can set the copy field to be read-only and then user won't be able to edit it.

Note, though, that the text in this field will not "re-flow" the rest of the sentence. To do that the entire text needs to be a part of the same field.

2 replies

Bernd Alheit
Community Expert
Community Expert
July 24, 2019

Use a field for the whole header and a field for the whole body.

try67
Community Expert
Community Expert
July 24, 2019

You can copy and paste the fields from the first page to the other pages, and they'll all have the same value automatically.

prop281218
Participating Frequently
July 24, 2019

Thanks for the speedy response. That does work to some degree, however this means the form field is visible on the populated areas. I'm looking for these to look like part of the same sentence and not an editable area, as such.

Is there a way around that?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 24, 2019

For that you will need to use fields with unique names and a simple script to copy the value other.

For example, if the editable field is called "Name" and the copy is called "NameCopy", use the following code as the custom calculation script of the latter:

event.value = this.getField("Name").valueAsString;

Then you can set the copy field to be read-only and then user won't be able to edit it.

Note, though, that the text in this field will not "re-flow" the rest of the sentence. To do that the entire text needs to be a part of the same field.