Text keeps changing to default when leaving text field

New Here ,
Mar 15, 2019

Copy link to clipboard

Copied

I have a drop down menu in a PDF  called "selectedReg" that changes a text field.

I have the following in the Custom calculation script for the text field:

if (selectedReg=="1") event.value = "Text for option 1";

else if (selectedReg=="2") event.value = "Text for option 2";

else if (selectedReg=="3") event.value = "Text for option 3";

After the text is displayed, I need to add some additional text to it.  But when I click out of the text field it will keep reverting to the default value.

Any easy way that I can make changes to the text field and make them stay?

Thanks!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You need to move the code to the custom validation script of the drop-down and change it to this:

var f = this.getField("name of text field");

if (event.value=="1") f.value = "Text for option 1";

else if (event.value=="2") f.value = "Text for option 2";

else if (event.value=="3") f.value = "Text for option 3";

TOPICS
Acrobat SDK and JavaScript, Windows

Views

79

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

Text keeps changing to default when leaving text field

New Here ,
Mar 15, 2019

Copy link to clipboard

Copied

I have a drop down menu in a PDF  called "selectedReg" that changes a text field.

I have the following in the Custom calculation script for the text field:

if (selectedReg=="1") event.value = "Text for option 1";

else if (selectedReg=="2") event.value = "Text for option 2";

else if (selectedReg=="3") event.value = "Text for option 3";

After the text is displayed, I need to add some additional text to it.  But when I click out of the text field it will keep reverting to the default value.

Any easy way that I can make changes to the text field and make them stay?

Thanks!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You need to move the code to the custom validation script of the drop-down and change it to this:

var f = this.getField("name of text field");

if (event.value=="1") f.value = "Text for option 1";

else if (event.value=="2") f.value = "Text for option 2";

else if (event.value=="3") f.value = "Text for option 3";

TOPICS
Acrobat SDK and JavaScript, Windows

Views

80

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
Mar 15, 2019 0
Most Valuable Participant ,
Mar 15, 2019

Copy link to clipboard

Copied

You need to move the code to the custom validation script of the drop-down and change it to this:

var f = this.getField("name of text field");

if (event.value=="1") f.value = "Text for option 1";

else if (event.value=="2") f.value = "Text for option 2";

else if (event.value=="3") f.value = "Text for option 3";

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...
Mar 15, 2019 1
New Here ,
Mar 18, 2019

Copy link to clipboard

Copied

Perfect, thanks!

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...
Mar 18, 2019 0