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

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.

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;

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

355

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

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

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.

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;

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

356

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

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
Reply
Loading...
May 23, 2020 0
Explorer ,
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?

 

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
Reply
Loading...
May 23, 2020 0
Adobe Community Professional ,
May 29, 2020

Copy link to clipboard

Copied

Check your calculation order.

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
Reply
Loading...
May 29, 2020 0