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

Creating a referenced text field in a form

Guest
Jun 14, 2017 Jun 14, 2017

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.)

TOPICS
PDF forms
8.2K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jun 15, 2017 Jun 15, 2017

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!

View solution in original post

Translate
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 ,
Jun 14, 2017 Jun 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.

Translate
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
Guest
Jun 14, 2017 Jun 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.

Translate
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 ,
Jun 14, 2017 Jun 14, 2017

Drop-down and combo-box are the same thing.

Translate
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
Guest
Jun 14, 2017 Jun 14, 2017

Okay, so I've got my dropdown list (called Dropdown2), and a text field I want to change (called NPI).

Under Dropdown Properties, Format, format category: Custom, Custom Keystroke Script - Edit

I added:

if( event.willCommit ) {

    if(event.value == "") this.resetForm(["NPI"]); else SetFieldValues(event.value);

}

On the instructions page there is a section that doesn't work in the current version of adobe:

Unless this is meant to be "custom format script" on the same format page

Translate
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 ,
Jun 14, 2017 Jun 14, 2017

It's not what is intended there, but if you place the SetFieldValues in the Keystroke script it should work, yes.

Translate
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
Guest
Jun 15, 2017 Jun 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.

Translate
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 ,
Jun 15, 2017 Jun 15, 2017

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!

Translate
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
Guest
Jun 15, 2017 Jun 15, 2017

Brilliant, this makes much more sense. I played around with it and was able to get it to work.

So, as long as I add this to the Validate tab (Run custom validation script) on my original drop-down list, I can reference any additional fields/drop-down lists on the form by properly referencing them in the get.Field("fieldname") and setting whatever value I want hard coded for that original selection (in this case a name).

What's also helpful is that I can just create other selection fields and I don't have to worry about populating them with data, since I'm going to hard-code the information into the validation script. Saving me a lot of time, thanks try67​

Translate
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 ,
Jun 15, 2017 Jun 15, 2017
LATEST

Yes, that's correct. Just make sure you use the right syntax. It's getField, not get.Field ...

Translate
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