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

Populating text from dropdown menu

New Here ,
Apr 11, 2018 Apr 11, 2018

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
1.4K
Translate
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.

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

Where did you place this code?

Translate
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

I have this code under calculate section, custom script.

Translate
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

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

Translate
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

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.

Translate
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

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

Translate
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

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.

Translate
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

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.

Translate
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

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

Translate
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

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

Translate
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
Translate
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

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

Translate
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

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.

Translate
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

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.

Translate
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

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

Translate
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

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.

Translate
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

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

Translate
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

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.

Translate
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

Again, you'll need to share the file.

Translate
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

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

Translate
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

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?

Translate
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

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

Translate
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

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

Translate
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
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

Translate
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