Populating text from dropdown menu

New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

I have a dropdown menu, that when an item is selected a description appears in a text box from the selection in the dropdown list. This is the script I already have, but it only shows for the first item in the dropdown list. I need help getting the text field to show from every selection in my dropdown list.

var v = event.value;

var targetValue = "";

if (v == "Appliance Repair")'

{

     targetValue = "Text";

}

else if (v == "Carpet Repair")

{

     targetValue = "Text2";

}

this.getField("Description").value = targetValue;

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You had a bunch of issues with conflicting scripts in multiple fields. I fixed it for you in the attached file:

Test Document_edited.pdf - Google Drive

You should study the code and where it's placed, for future reference.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

338

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

Populating text from dropdown menu

New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

I have a dropdown menu, that when an item is selected a description appears in a text box from the selection in the dropdown list. This is the script I already have, but it only shows for the first item in the dropdown list. I need help getting the text field to show from every selection in my dropdown list.

var v = event.value;

var targetValue = "";

if (v == "Appliance Repair")'

{

     targetValue = "Text";

}

else if (v == "Carpet Repair")

{

     targetValue = "Text2";

}

this.getField("Description").value = targetValue;

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

You had a bunch of issues with conflicting scripts in multiple fields. I fixed it for you in the attached file:

Test Document_edited.pdf - Google Drive

You should study the code and where it's placed, for future reference.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

339

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
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

Where did you place this 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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

I have this code under calculate section, custom script.

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...
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

It should be used as the custom validation script of the drop-down field.

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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

Ok, I've placed it there now and still only one item in the dropdown list populates a description in my text field. When I select to another selection the text field does not populate.

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...
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

Go to the Properties of the drop-down field, Options tab, and tick the "Commit selected value immediately" box.

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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

Yes, that is already selected. I do not understand how it will complete the script off of the first selection, but after that nothing appears.

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...
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

Maybe you didn't enter the exact same text into the script as appears in the field's options list... Even if a single character is not exactly the same (including lower/upper-case, spaces, etc.), it won't work.

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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

Everything matches, is it possible for me to upload a link to document in drop box and you take a look?

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...
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

Yes. Use Dropbox, Google Drive, Adobe Cloud, etc., and post the link here.

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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

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...
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

I don't see where you placed the script...

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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

Check the facility request dropdown and it is under the calculated tab. you may have to move the dropdown boxes from over top of each other so that you can essentially check the dropdown properties.

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...
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

You had a bunch of issues with conflicting scripts in multiple fields. I fixed it for you in the attached file:

Test Document_edited.pdf - Google Drive

You should study the code and where it's placed, for future reference.

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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

Appreciate it, I had multiple script because of the other actions I needed done for the document.

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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

Just wanted to say, for some reason when I copy the existing code into another pdf form that is an exact replica, it still has issues after the first selection.

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...
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

Make sure you've removed all the calculation scripts from all of the fields involved.

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...
Apr 11, 2018 0
New Here ,
Apr 11, 2018

Copy link to clipboard

Copied

Yes, I did and then I just went and placed the script you implemented in the designated spots and the script for the populated text doesn't work pass the first selection. Now the script for the drop down to show or hide the other dropdown works from document to document.

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...
Apr 11, 2018 0
Most Valuable Participant ,
Apr 11, 2018

Copy link to clipboard

Copied

Again, you'll need to share the file.

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...
Apr 11, 2018 0
New Here ,
Apr 12, 2018

Copy link to clipboard

Copied

I looked at it closely and figured out what I had wrong. Thank you again for all the help.

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...
Apr 12, 2018 0
New Here ,
Apr 12, 2018

Copy link to clipboard

Copied

I have one last question, is it possible where I have the date field to populate a calendar so that it can be selected to fill in rather then someone typing?

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...
Apr 12, 2018 0
Adobe Community Professional ,
Apr 12, 2018

Copy link to clipboard

Copied

Acrobat/Reader DC has an automatic calendar popup for any field with Date formatting.

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...
Apr 12, 2018 0
New Here ,
Apr 12, 2018

Copy link to clipboard

Copied

Adobe acrobat XI pro doesn’t show it. So are you saying a person must own a subscription to adobe pro DC?

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...
Apr 12, 2018 0
Adobe Community Professional ,
Apr 12, 2018

Copy link to clipboard

Copied

No, all they need is the Free Acrobat Reader.

But if you want to add an explicit calendar popup to your form, there is a free one here:

Free Sample PDF Files with scripts

However, this is from back in the pre-DC days.  Now that there is an automatic calendar popup, you'll need to add code to test the user's version before displaying it to prevent a conflict.

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...
Apr 12, 2018 0