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

How to get a field to fill with a string that is it's own value plus values from two other fields

Explorer ,
May 23, 2020 May 23, 2020

Copy link to clipboard

Copied

Have seen similar ideas but don't think I know the commands to do this in Javascript.

Here are my two situations.

SITUATION 1

I have the text Fields F1 and F2, and a Dropdown box field D1.

I want the value dispalyed in F1 to be "text string which I enter" D1  F2

Example, "text string which I enter"  = "Stopped smoking?"   

Field D1 options "Y","N", say Y is selected

Field F2 is a number (calculated elsewhere), let's say 3.

So I would like it to appear in Field F1 as "Stopped smoking?   Y   3"

 

SITUATION 2

Similar to the above except there is no D1,  Field F1 is now a dropdown box and would like to use the value selected in the F1 dropdown list to create the output displayed in Field F1 as  "value selcted in F1  F2value"  

Do need to put a space between each of these values so it can be read easily.

Would need to be able to select on F1 again and get the original drop down list and have it rewrite if a new selection is made.

In this case the length of the items in F1 varies greatly and want to append a number from field F2 at the end of the F1 item.  Currently F2 is a seperate field right after F1 but sometimes the gap between text and number is very large.

 

Thanks  in advance for your help.

TOPICS
Acrobat SDK and JavaScript

Views

615

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

Explorer , May 23, 2020 May 23, 2020

Solved Situation 1 (by a bit more searching) with the following as a custom calculation:

event.value = "text string which I enter" + this.getField("D1").valueAsString + this.getField("F2").valueAsString;

Votes

Translate

Translate
Explorer ,
May 23, 2020 May 23, 2020

Copy link to clipboard

Copied

Solved Situation 1 (by a bit more searching) with the following as a custom calculation:

event.value = "text string which I enter" + this.getField("D1").valueAsString + this.getField("F2").valueAsString;

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
Explorer ,
May 23, 2020 May 23, 2020

Copy link to clipboard

Copied

Partial Solution for Siutation 2 UPDATED Question.

So implimented this in a custom calculation  in dropbox field F1

Solved Situation 1 (by a bit more searching) with the following as a custom calculation:

 

event.value = this.getField("F1").valueAsString + this.getField("F2").valueAsString;

 

It works except field F1 does not autoupdate if you change field F2, is there anyway to force it to update F1 when F2 changes?

 

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 ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

LATEST

Check your calculation order.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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