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

Fillable PDF - Populate one Field based on another

Explorer ,
Oct 02, 2020 Oct 02, 2020

Copy link to clipboard

Copied

Updating a paper form to a fillable PDF.

Three pieces of information are required.  Inspector, ID Number and Territory

I have a drop down of inspector names.  The IDNumber and Territory will change depending on the name that is chosen.  

 

Would I set up a Javascript Action on the Inspector Field and populate the other from there, or set up a Javascript Action on the other two fields?

 

Can anyone give me a quick example of how this might look?  My Javascript skills have rusted from 10 years of no use.  🙂

Thanks!

TOPICS
Create PDFs , Edit and convert PDFs , PDF forms

Views

422

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 , Oct 02, 2020 Oct 02, 2020

You can do it either way. If you want the user to be able to fill in those fields manually at some point then you can use the Valiadtion event of the drop-down. That also has the advantage of having all the code in a single location.

An example script for that would be:

 

if (event.value=="John Doe") {

this.getField("ID").value = "123";

this.getField("Territory").value = "Alaska";

} else if (event.value=="Mary Jane") {

this.getField("ID").value = "456";

this.getField("Territory").value = "Idaho"

...

Votes

Translate

Translate
Community Expert ,
Oct 02, 2020 Oct 02, 2020

Copy link to clipboard

Copied

You can do it either way. If you want the user to be able to fill in those fields manually at some point then you can use the Valiadtion event of the drop-down. That also has the advantage of having all the code in a single location.

An example script for that would be:

 

if (event.value=="John Doe") {

this.getField("ID").value = "123";

this.getField("Territory").value = "Alaska";

} else if (event.value=="Mary Jane") {

this.getField("ID").value = "456";

this.getField("Territory").value = "Idaho";

} // etc.

else {

this.getField("ID").value = "";

this.getField("Territory").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 ,
Oct 08, 2020 Oct 08, 2020

Copy link to clipboard

Copied

This works for what I was trying to do.  Works great!   There is talk about adding one more dropdown for Inspection Type.   We would populate our inspector list based on the selection in Inspection Type.  Any pointers for this type of request.

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 ,
Oct 08, 2020 Oct 08, 2020

Copy link to clipboard

Copied

LATEST

You can add nested if-statements, or additional conditions, like this:

 

 

var inspectionType = this.getField("InspectionType").valueAsString;

if (event.value=="John Doe" && inspectionType=="Regular") {

this.getField("ID").value = "123";

this.getField("Territory").value = "Alaska";

} else if (event.value=="John Doe" && inspectionType=="Premium") {

this.getField("ID").value = "999";

this.getField("Territory").value = "Hawaii";

}

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