Skip to main content
Known Participant
September 29, 2020
Answered

Populating a text field from responses in Dropdown field

  • September 29, 2020
  • 2 replies
  • 973 views

I am reasonably new to PDF forms and want to develop my skills during the COVID lockdown.  

I am trying to auto-populate a text field based in the dropdown box selection.  i.e if "Dropdown1" selection is "Paul" then "Text1" would auto-populate with "Melbourne" if "Dropdown1" selection is "Terry" then "Text1" would auto-populate with "Adelaide" and so on.

I am sure this is probably quite easy, but at the moment is beyond my skill level.

Thanks in advance

Paul

This topic has been closed for replies.
Correct answer ls_rbls

It is quite easy to do this with a combination of the Acrobat built-in features for the comboboxes and a little bit of JavaScript scripting.

 

However, if your dropdown menu has over 10 listed items it becomes quite an annoyance to do this manually, in which case, you'll need to fully employ a more elaborated script.

 

But the easiest way for me would be to manually enter the list item "Paul" and assign its export value "Melbourne" . Do the same for each entry that you add.

 

See slide:

 

 

Then you can add a custom calculation script in "text1" field like :

 

 

 

event.value = this.getField("Dropdown1").value;

 

 

 

2 replies

ls_rbls
ls_rblsCorrect answer
Adobe Expert
September 29, 2020

It is quite easy to do this with a combination of the Acrobat built-in features for the comboboxes and a little bit of JavaScript scripting.

 

However, if your dropdown menu has over 10 listed items it becomes quite an annoyance to do this manually, in which case, you'll need to fully employ a more elaborated script.

 

But the easiest way for me would be to manually enter the list item "Paul" and assign its export value "Melbourne" . Do the same for each entry that you add.

 

See slide:

 

 

Then you can add a custom calculation script in "text1" field like :

 

 

 

event.value = this.getField("Dropdown1").value;

 

 

 

Paul5D64Author
Known Participant
October 1, 2020

Thank you ls-rbls.  Your idea works a treat and has shown me how much more I need to learn.  Thank you again 

Nesa Nurani
Adobe Expert
September 29, 2020

You can use this code as custom calculation script of text1 field:

var drop = this.getField("Dropdown1").valueAsString;
if(drop == "Paul"){event.value = "Melbourne";}
else if(drop == "Terry"){event.value = "Adelaide";}
else event.value = "";

Paul5D64Author
Known Participant
October 1, 2020

Thank you NesaNurani, I will be having a close look at using this in my current and future forms.  Thanks again for your help.