
Copy link to clipboard
Copied
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
Name | numbers |
---|---|
John Smith | 760-123-4567 |
Dave Allen | 321-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.)
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.

Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Drop-down and combo-box are the same thing.

Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
It's not what is intended there, but if you place the SetFieldValues in the Keystroke script it should work, yes.

Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!

Copy link to clipboard
Copied
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​
Copy link to clipboard
Copied
Yes, that's correct. Just make sure you use the right syntax. It's getField, not get.Field ...

