• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Populating text from dropdown menu

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

TOPICS
Acrobat SDK and JavaScript , Windows

Views

887

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
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 11, 2018 Apr 11, 2018

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.

Votes

Translate

Translate
Community Expert ,
Apr 11, 2018 Apr 11, 2018

Copy link to clipboard

Copied

Where did you place this code?

Votes

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
community guidelines
New Here ,
Apr 11, 2018 Apr 11, 2018

Copy link to clipboard

Copied

I have this code under calculate section, custom script.

Votes

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
community guidelines
Community Expert ,
Apr 11, 2018 Apr 11, 2018

Copy link to clipboard

Copied

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

Votes

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

Votes

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
community guidelines
Community Expert ,
Apr 11, 2018 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.

Votes

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

Votes

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
community guidelines
Community Expert ,
Apr 11, 2018 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.

Votes

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
community guidelines
New Here ,
Apr 11, 2018 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?

Votes

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
community guidelines
Community Expert ,
Apr 11, 2018 Apr 11, 2018

Copy link to clipboard

Copied

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

Votes

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
community guidelines
New Here ,
Apr 11, 2018 Apr 11, 2018

Copy link to clipboard

Copied

Votes

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
community guidelines
Community Expert ,
Apr 11, 2018 Apr 11, 2018

Copy link to clipboard

Copied

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

Votes

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

Votes

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
community guidelines
Community Expert ,
Apr 11, 2018 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.

Votes

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

Votes

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

Votes

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
community guidelines
Community Expert ,
Apr 11, 2018 Apr 11, 2018

Copy link to clipboard

Copied

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

Votes

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

Votes

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
community guidelines
Community Expert ,
Apr 11, 2018 Apr 11, 2018

Copy link to clipboard

Copied

Again, you'll need to share the file.

Votes

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

Votes

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
community guidelines
New Here ,
Apr 12, 2018 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?

Votes

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
community guidelines
Community Expert ,
Apr 12, 2018 Apr 12, 2018

Copy link to clipboard

Copied

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

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
New Here ,
Apr 12, 2018 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?

Votes

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
community guidelines
Community Expert ,
Apr 12, 2018 Apr 12, 2018

Copy link to clipboard

Copied

LATEST

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.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines