Expand my Community achievements bar.

SOLVED

How do I auto-populate text field based on auto-populated data in drop down list?

Avatar

Level 2

I have created a drop-down list which includes various regions.  When a region is selected it auto-populates another drop-down list with locations.  I would like to auto-populate a text field with pre-determined phone numbers once a location is selected from the "locations" drop-down list.  I want to embed the phone numbers in the code since the form will not be accessing a database.  Any help would be greatly appreciated.  Thanks, Ed.

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi,

Here is the link to your form. https://acrobat.com/#d=BaCL7BKKdAcgV3JIk61nZg

You have field mis matches in the change event of 2nd DropDown.

While referencing it you are using .page1 while your page is Page1.

Thanks.

Bibhu.

View solution in original post

7 Replies

Avatar

Level 9

Hi,

You can do this by putting some scripts in the change event of the 2nd DropDown list (locations).

var newVal = this.boundItem(xfa.event.newText);

switch (newVal)                                   
{
    case "SomeItems in location DropDown":
        form1.page1.PhoneField.rawValue = "";     // Clears any previous existing values.   
        form1.page1.State.rawValue = "The phone number you want to set";
        break;
   case "SomeItems in location DropDown":
         form1.page1.PhoneField.rawValue = "";     
         form1.page1.State.rawValue = "The phone number you want to set";
         break;

default:
    break;
}

Thanks.

Bibhu.

Avatar

Level 2

Hi Bibhu,

Thanks for the quick response. Unfortunately, I am still not able to get the text field to display properly. I have attached a copy of the form, with the new script already embedded. Please let me know what I am doing wrong.

Thanks,

Ed Watson

Avatar

Level 2

It doesn't look like my attachment went through. Here's the script:

</field

Avatar

Level 9

Hi,

Sorry. I can not see your script. Please upload the form in Acrobat.com and give the link here.

Thanks.

Bibhu.

Avatar

Correct answer by
Level 9

Hi,

Here is the link to your form. https://acrobat.com/#d=BaCL7BKKdAcgV3JIk61nZg

You have field mis matches in the change event of 2nd DropDown.

While referencing it you are using .page1 while your page is Page1.

Thanks.

Bibhu.