• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Text variables with javascript?

New Here ,
Jul 24, 2019 Jul 24, 2019

Copy link to clipboard

Copied

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!

TOPICS
Acrobat SDK and JavaScript

Views

707

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

correct answers 1 Correct answer

Community Expert , Jul 24, 2019 Jul 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 entir

...

Votes

Translate

Translate
Community Expert ,
Jul 24, 2019 Jul 24, 2019

Copy link to clipboard

Copied

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

Votes

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
New Here ,
Jul 24, 2019 Jul 24, 2019

Copy link to clipboard

Copied

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?

Votes

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 ,
Jul 24, 2019 Jul 24, 2019

Copy link to clipboard

Copied

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.

Votes

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
New Here ,
Jul 24, 2019 Jul 24, 2019

Copy link to clipboard

Copied

Wow! Thank you so much, that really does exactly what I needed!

try67  wrote

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.

How would I include the rest of the text into the field as well?

Votes

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 ,
Jul 24, 2019 Jul 24, 2019

Copy link to clipboard

Copied

Use something like this:

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

Votes

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
New Here ,
Jul 24, 2019 Jul 24, 2019

Copy link to clipboard

Copied

LATEST

Amazing guys! Thank you both very much!

Votes

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 ,
Jul 24, 2019 Jul 24, 2019

Copy link to clipboard

Copied

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

Votes

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