Skip to main content
June 14, 2017
Answered

Creating a referenced text field in a form

  • June 14, 2017
  • 1 reply
  • 8605 views

I'm trying to create a form that uses a drop down field list of names (easy part), and automatically fills out another field below of a related phone number.

(e.g. On the Form, "Who is your doctor?" Drop down list: [select provider], next field below: [provider phone number])

I was thinking that a number could be hard coded to a specific selection

Namenumbers
John Smith760-123-4567
Dave Allen321-457-1872
Brenda perkins

212-858-9163

So if a user selects "John Smith" from the drop-down list, the next part of the form auto-populates with the correct corresponding number (760-123-4567)

obviously instead of phone numbers it could be anything, I'd like to be able to repeat the process for other bits of information to streamline the form filling process (addresses etc.)

This topic has been closed for replies.
Correct answer try67

I'm not a programmer so I have no idea how to get it to work, the pdf files on the linked page

(https://acrobatusers.com/tutorials/change_another_field ) didn't give much insight into how the code functions.

So my post above for custom keystroke script was a barely modified "cargo cult" programming style in which I barely modified the code, I'm unsure what will actually happen.


I think that tutorial over-complicates things, to be honest, so I'm not surprised you got a bit lost.

Here's what I would do. Use a custom validation script with this code:

if (event.value=="John Smith") this.getField("PhoneNumber").value = "760-123-4567";

else if (event.value=="Dave Allen") this.getField("PhoneNumber").value = "321-457-1872";

else if (event.value=="Brenda perkins") this.getField("PhoneNumber").value = "212-858-9163"; // etc.

else this.getField("PhoneNumber").value = "";

Then set the option (under Properties - Options) to commit the selected value of the drop-down field immediately, and you're done!

1 reply

try67
Community Expert
June 14, 2017

Yes, that's possible. See this tutorial: https://acrobatusers.com/tutorials/change_another_field

I've also developed a tool that allows you to easily set up such an operation, based on a spreadsheet that contains all the data:

Custom-made Adobe Scripts: Acrobat -- Populate Fields From Dropdown

But if you only want to populate one other field then it can be done with a relatively simple script.

June 14, 2017

I'm not sure if I have the right version.

In the tutorial they reference using a combo box, which I don't have

I have (highlighted from left to right): text, check box, radio buttons, list of choices, dropdown list, print/clear button, signature, barcode.

try67
try67Correct answer
Community Expert
June 15, 2017

I'm not a programmer so I have no idea how to get it to work, the pdf files on the linked page

(https://acrobatusers.com/tutorials/change_another_field ) didn't give much insight into how the code functions.

So my post above for custom keystroke script was a barely modified "cargo cult" programming style in which I barely modified the code, I'm unsure what will actually happen.


I think that tutorial over-complicates things, to be honest, so I'm not surprised you got a bit lost.

Here's what I would do. Use a custom validation script with this code:

if (event.value=="John Smith") this.getField("PhoneNumber").value = "760-123-4567";

else if (event.value=="Dave Allen") this.getField("PhoneNumber").value = "321-457-1872";

else if (event.value=="Brenda perkins") this.getField("PhoneNumber").value = "212-858-9163"; // etc.

else this.getField("PhoneNumber").value = "";

Then set the option (under Properties - Options) to commit the selected value of the drop-down field immediately, and you're done!