Populate a text field with the same content (not value) of a dropdown list

Community Beginner ,
Jun 13, 2019

Copy link to clipboard

Copied

Hi. I have a dropdown list "Dropdown1" with some values that show the relative content, for example:

- value = 0 shows " "

- value = 1 shows "abc"

- value = 2 shows "def"

- value = 3 shows "ghi"

Now, I have a text field "Text1". I would like that when I select a value in the list, this populates the text field with the same content. I know I can use this calculation script in "Text1":

var f = this.getField("Dropdown1"); 

if (f.valueAsString=="0") event.value = " "; 

else if (f.valueAsString=="1") event.value = "abc";

else if (f.valueAsString=="2") event.value = "def";

else if (f.valueAsString=="3") event.value = "ghi";

but if if I allow to customize the text of the selection of the dropdown list, this change (rightly) does not appear in the text field. I would like to work around the problem and impose that the content (and not the value) that appears in the list, appears identical even in the text field. Thanks

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Not sure what you mean by the distinction between "content" and "value", unless you're referring to the export values... Anyway, the solution to this issue is quite simple. Add this line to the end of your code:

else event.value = f.valueAsString;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

57

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

Populate a text field with the same content (not value) of a dropdown list

Community Beginner ,
Jun 13, 2019

Copy link to clipboard

Copied

Hi. I have a dropdown list "Dropdown1" with some values that show the relative content, for example:

- value = 0 shows " "

- value = 1 shows "abc"

- value = 2 shows "def"

- value = 3 shows "ghi"

Now, I have a text field "Text1". I would like that when I select a value in the list, this populates the text field with the same content. I know I can use this calculation script in "Text1":

var f = this.getField("Dropdown1"); 

if (f.valueAsString=="0") event.value = " "; 

else if (f.valueAsString=="1") event.value = "abc";

else if (f.valueAsString=="2") event.value = "def";

else if (f.valueAsString=="3") event.value = "ghi";

but if if I allow to customize the text of the selection of the dropdown list, this change (rightly) does not appear in the text field. I would like to work around the problem and impose that the content (and not the value) that appears in the list, appears identical even in the text field. Thanks

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Not sure what you mean by the distinction between "content" and "value", unless you're referring to the export values... Anyway, the solution to this issue is quite simple. Add this line to the end of your code:

else event.value = f.valueAsString;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

58

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
Jun 13, 2019 0
Most Valuable Participant ,
Jun 13, 2019

Copy link to clipboard

Copied

Not sure what you mean by the distinction between "content" and "value", unless you're referring to the export values... Anyway, the solution to this issue is quite simple. Add this line to the end of your code:

else event.value = f.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...
Jun 13, 2019 0