Combining text fields into one to create a description

Explorer ,
Jul 25, 2019 Jul 25, 2019

Copy link to clipboard

Copied

Hello everyone, I'm trying to create a group of fields that would have pre-populated text in the export value. Then combine those fields into one, which would make a complete sentence (or paragraph) of those field values. For example, Field1 would have "We propose to install". Then in Field2 would have the (total footage) "of 8' high CLF". In Field3 would have the total footage then "8' high WIF". In Field3 would have pretty much the same but this would be "of 8' high Wood Fence". Giving me the choice to show/hide the particular fields.

Is this something that can be done using javascript? I don't know enough but I'd like to learn. Or, does anyone know of a way to accomplish something like this in a PDF. I'd like to create a short cut to be able to put the combinations into a job description. If you can show me how to create the first one, then I can do the rest. Thank you all so much.

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

301

Likes

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

Adobe Community Professional , Jul 26, 2019 Jul 26, 2019
Sure. In the code, change all instances of "valueAsString" to "defaultValue".

Likes

Translate

Translate
Adobe Community Professional ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

Yes, this is easily done. You can use something like this as the custom calculation script of the final field:

event.value = this.getField("Field1").valueAsString + this.getField("Field2").valueAsString + this.getField("Field3").valueAsString;

Likes

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
Explorer ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

Heya Gilad, thanks for the quick response. The script works, but only when I type some text into the field. What I would like to do is not have to type and have the text filled in the default value of each text field and have that text fill into the end text field. I'll probably hide the fields and only show them when needed. Can that be done?

Likes

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
Adobe Community Professional ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

I don't understand what you mean... You want to combine the default values, not the actual values?

Likes

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
Explorer ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

Yes. Is that possible? The Text Field Properties window. Options > Default Value. I have just typed in some text there and it doesn't change.

Likes

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
Adobe Community Professional ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

Sure. In the code, change all instances of "valueAsString" to "defaultValue".

Likes

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
Explorer ,
Jul 26, 2019 Jul 26, 2019

Copy link to clipboard

Copied

Right on the money. Thanks, Gilad. That was perfect. Now for part 2. I would like the default values to populate into the destination text field only if one or all 3 text fields are visible.

Likes

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
Adobe Community Professional ,
Jul 27, 2019 Jul 27, 2019

Copy link to clipboard

Copied

You can use something like this, then:

var f1 = this.getField("Field1");

var f2 = this.getField("Field2");

var f3 = this.getField("Field3");

if (f1.display==display.visible || f2.display==display.visible || f3.display==display.visible)

    event.value = f1.defaultValue + f2.defaultValue + f3.defaultValue;

else event.value = "";

Likes

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
Explorer ,
Jul 27, 2019 Jul 27, 2019

Copy link to clipboard

Copied

LATEST

Interesting. I'll have to play around with it later. You definitely know your stuff. Thanks for all your time.

Likes

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