How can I populate other text fields when I click on an option (list box)?

New Here ,
Jan 31, 2019

Copy link to clipboard

Copied

So a helpful member of the community helped me with JS that will populate other text fields based on a selection. Now the issue is, these text fields don't populate as soon as you click on them. Can anyone help please with how I may be able to accomplish this, more info:

I can't work Option2 to populate its values to the fields when I click on it. PDF options issue.GIF

Here is the code:

var text1Value = "";

var text2Value = "";

switch (this.getField("dropdownList").value)

{

    case "Option1":

         text1Value = "Option1Value";

         text2Value = "Option1Value";       

          break;

    case "Option2":

         text1Value = "Option2Value";

         text2Value = "Option2Value";       

          break;

     default:

          text1Value = "Please select an option for this field to populate";

          text2Value = "Please select an option for this field to populate";

          break;

}

this.getField ("text1").value = text1Value;

this.getField("text2").value = text2Value;

-----------------------------------------------

Thank you for your help!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Where did you place the code?

TOPICS
Acrobat SDK and JavaScript

Views

100

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

How can I populate other text fields when I click on an option (list box)?

New Here ,
Jan 31, 2019

Copy link to clipboard

Copied

So a helpful member of the community helped me with JS that will populate other text fields based on a selection. Now the issue is, these text fields don't populate as soon as you click on them. Can anyone help please with how I may be able to accomplish this, more info:

I can't work Option2 to populate its values to the fields when I click on it. PDF options issue.GIF

Here is the code:

var text1Value = "";

var text2Value = "";

switch (this.getField("dropdownList").value)

{

    case "Option1":

         text1Value = "Option1Value";

         text2Value = "Option1Value";       

          break;

    case "Option2":

         text1Value = "Option2Value";

         text2Value = "Option2Value";       

          break;

     default:

          text1Value = "Please select an option for this field to populate";

          text2Value = "Please select an option for this field to populate";

          break;

}

this.getField ("text1").value = text1Value;

this.getField("text2").value = text2Value;

-----------------------------------------------

Thank you for your help!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Where did you place the code?

TOPICS
Acrobat SDK and JavaScript

Views

101

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
Jan 31, 2019 0
Most Valuable Participant ,
Jan 31, 2019

Copy link to clipboard

Copied

If that field is a list-box, make sure to tick the "Commit selected value immediately" box under its Properties, Options tab.

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...
Jan 31, 2019 0
New Here ,
Jan 31, 2019

Copy link to clipboard

Copied

Thanks, the "Commit selected value immediately" has been selected. Still not changing based on clicking events.

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...
Jan 31, 2019 0
Most Valuable Participant ,
Jan 31, 2019

Copy link to clipboard

Copied

Where did you place the code?

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...
Jan 31, 2019 1
New Here ,
Jan 31, 2019

Copy link to clipboard

Copied

This is actually a great question!! I put the code on the overall document instead of putting it in Dropdownlist box. Once I put it there, things started working as expected! Thank you!

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...
Jan 31, 2019 0