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

Adobe PDF linking text fields

Explorer ,
Mar 21, 2023 Mar 21, 2023

Copy link to clipboard

Copied

Hi, can anyone help me with the Q in this scenario please?

I want to link three different text fields together, Field 1 (Mechanical), Field 2 (Electrical) and Field 3 (job description). Users for the form are supposed to choose between Field 1 and Field 2 to put in the job description, and that will populate into Field 3, so how can I achieve it? Because I have to name Field 1 and 2 differently to make them appear or disappear with radio buttons.

 

Thanks very much

 

Regards,

TOPICS
Acrobat SDK and JavaScript

Views

209

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 2 Correct answers

Community Expert , Mar 21, 2023 Mar 21, 2023

Use this as custom calculation script of Field 3 (job description):

var f1 = this.getField("Mechanical").valueAsString;
var f2 = this.getField("Electrical").valueAsString;
if(f1)
event.value = f1;
else if(f2)
event.value = f2;
else
event.value = "";

 

Votes

Translate

Translate
Community Expert , Mar 22, 2023 Mar 22, 2023

Yes, you do, but if you name them consistently ("Mechanical1", "Electric1", "Job Description1", "Mechanical2", "Electric2", "Job Description2", etc.) then it can be automated using a script. The code itself can be placed as a doc-level function and then just called from each field.

 

By the way, I would also add a script to each of the first fields to clear the value of the other one, if you want to make sure they are not both filled at the same time. Something like this can be used as the custo

...

Votes

Translate

Translate
Community Expert ,
Mar 21, 2023 Mar 21, 2023

Copy link to clipboard

Copied

Use this as custom calculation script of Field 3 (job description):

var f1 = this.getField("Mechanical").valueAsString;
var f2 = this.getField("Electrical").valueAsString;
if(f1)
event.value = f1;
else if(f2)
event.value = f2;
else
event.value = "";

 

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 ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

Thanks Nesa, it works, is there a way to implement it if I have nearly a hundred "Field 3"s, or do I have to put the script to each F3 individually? Appreciate your help.

Regards,

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 ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

LATEST

Yes, you do, but if you name them consistently ("Mechanical1", "Electric1", "Job Description1", "Mechanical2", "Electric2", "Job Description2", etc.) then it can be automated using a script. The code itself can be placed as a doc-level function and then just called from each field.

 

By the way, I would also add a script to each of the first fields to clear the value of the other one, if you want to make sure they are not both filled at the same time. Something like this can be used as the custom Validation script of "Mechanical1", for example:

if (event.value) this.getField("Electric1").value = "";

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