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

data change in a PDF based off a dropdown selection

New Here ,
Nov 03, 2022 Nov 03, 2022

Copy link to clipboard

Copied

Hello, I am trying to combine three different forms we have at work into one. The only difference is some addresses and phone number information. It differs between each of our locations. I want to combine them into one, where a customer can select the location in a drop down, and text fields will appear based on their selection, which would be the correct shipping and contact information on the form. 

 

I have went through a couple different threads and tried different codes but can't seem to either make it work correctly, or I am doing the wrong thing. Thank you for any help.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

602

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 ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Hi,

 

CAn you post the form ( or a sample form ) that has the drop down and the address fields that you are trying to use so that we can see the problem and offer a solution.

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
New Here ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Attached are the three forms I am trying to combine. If you look in the upper right, the name of the location is there. I was thinking about turning this into a drop down box and having each location listed. And when you select each location it pre fills all the address fields.

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 ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Do you mean that you want the "Ship To" address to change based on the dropdown selection?

 

If so, then this question has been answered many times, in fact weekly at least, on this forum. 

 

Here's some simple code that can be used in a validation script on the dropdown, it shows how you can accomplish this task, it doens't use the information from your form, you'll need to change the field names and data to fit your form.

 

 

if(event.value == "Location1")
   this.getField("ShipTo").value = "First Address";
else if(event.value == "Location2")
   this.getField("ShipTo").value = "Second Address";
else if(event.value == "Location3")
   this.getField("ShipTo").value = "Third Address";
else 
   this.getField("ShipTo").value = "";

 

 

This code uses a rather simple and direct solution. There are many other ways this could be done depending on the requirements of the specific form. 

Here are some articles that provide more detailed info.

https://acrobatusers.com/tutorials/change_another_field/

https://acrobatusers.com/tutorials/js_list_combo_livecycle/

https://acrobatusers.com/tutorials/list_and_combo_in_lc/

https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm

 

 

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
New Here ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

I need all data on the right side in part 2 to change. So it would need to be more than one field.

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 ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

LATEST

In that case, this simple solution is to expand the solution I already provided to include the new fields. 

 

if(event.value == "Location1"){
   this.getField("PartII_4A").value = "Something1";
   this.getField("ShipTo").value = "First Address";
}else if(event.value == "Location2"){
   this.getField("PartII_4A").value = "Something2";
   this.getField("ShipTo").value = "Second Address";
}else if(event.value == "Location3"){
   this.getField("PartII_4A").value = "Something3";
   this.getField("ShipTo").value = "Third Address";
}else{ 
   this.getField("PartII_4A").value = "";
   this.getField("ShipTo").value = "";
}

 

You can see how this technique gets more unwieldy as more fields are added.  But its straight forward and simple.
There are more sophisticted solutions that organize the data better, which are outlined in the articles I've linked in the previous post.   

 

 

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