Drop Down Field Need Name of Selection and Export Value

New Here ,
Aug 04, 2018

Copy link to clipboard

Copied

Greetings All,

I have a drop down field which has all the Countries Names (Afghanistan, Albania, etc.) and for the export values I used each county's 3 digit code (AFG, ALB, etc.)

After using this code for a few other fields, I need the actual country names when the user selects a country.

In essence, I need both the selection Name and the export value.

I would prefer not to create an if else tree for each export value to give me the name of country again (See Below):

if (this.getField("Birth_Country").value == AFG){

event.value = "Afghanistan";

} if (this.getField("Birth_Country").value == ALA){

event.value = "Albania";

//so on and so forth for 200+ countries

The end goal is to have a text field with the full name of the country "Afghanistan" and use the 3 letter acronym as part of an address "123 main st, kabul, AFG".

Any help would be appreciated.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

For the text field that should have the full name (let's say it's call "CountryFull"), enter the following code as the custom validation script of the drop-down field:

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

For the other fields use their calculation event and access the value like this to get the 3-letter code:

this.getField("Birth_Country").valueAsString

TOPICS
Acrobat SDK and JavaScript, Windows

Views

145

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Drop Down Field Need Name of Selection and Export Value

New Here ,
Aug 04, 2018

Copy link to clipboard

Copied

Greetings All,

I have a drop down field which has all the Countries Names (Afghanistan, Albania, etc.) and for the export values I used each county's 3 digit code (AFG, ALB, etc.)

After using this code for a few other fields, I need the actual country names when the user selects a country.

In essence, I need both the selection Name and the export value.

I would prefer not to create an if else tree for each export value to give me the name of country again (See Below):

if (this.getField("Birth_Country").value == AFG){

event.value = "Afghanistan";

} if (this.getField("Birth_Country").value == ALA){

event.value = "Albania";

//so on and so forth for 200+ countries

The end goal is to have a text field with the full name of the country "Afghanistan" and use the 3 letter acronym as part of an address "123 main st, kabul, AFG".

Any help would be appreciated.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

For the text field that should have the full name (let's say it's call "CountryFull"), enter the following code as the custom validation script of the drop-down field:

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

For the other fields use their calculation event and access the value like this to get the 3-letter code:

this.getField("Birth_Country").valueAsString

TOPICS
Acrobat SDK and JavaScript, Windows

Views

146

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 04, 2018 0
Most Valuable Participant ,
Aug 04, 2018

Copy link to clipboard

Copied

For the text field that should have the full name (let's say it's call "CountryFull"), enter the following code as the custom validation script of the drop-down field:

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

For the other fields use their calculation event and access the value like this to get the 3-letter code:

this.getField("Birth_Country").valueAsString

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 04, 2018 1