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

Creating a form that can populate a text field from a dropdown selection

New Here ,
Sep 28, 2017 Sep 28, 2017

I have created a from in Acrobat Pro Dc that is a report. I have a dropdown list called "speaking and listening" that I want to populate a text field field called "comment". I want the form to be able to make a selection from the list then add a sentence to the text field. The possible selections are:

Outstanding

High

Sound

Basic

Limited

I want there to be a different sentence for each selection. If have tried a few scripts but haven't been able to get any to work correctly.

I am hoping someone might be able to help.

Thank you

TOPICS
Acrobat SDK and JavaScript
3.1K
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 , Sep 28, 2017 Sep 28, 2017

See this great (and free) sample, data and JavaScript are all in the dropdown :

http://abracadabrapdf.net/parking/AcroUsers/Populate-text-field-from-dropdown.pdf

Translate
Community Expert ,
Sep 28, 2017 Sep 28, 2017

You say you want to "add a sentence to the text field". Do you mean that you want to keep whatever value it already has and the new sentence to it, or do you actually mean that you want to set the field's value to be that sentence?
Also, should the text field be editable by the user, or should its value only be determined by the value 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 ,
Sep 28, 2017 Sep 28, 2017

I mean I want the selection to stay in the drop down then a seperate sentence to appear in the text field.

E.g if sound is selected in the drop down the the text field would show "indicator for sound knowledge". Then if you selected high the text field would show "indicator for high knowledge" etc

the field would be blank so the sentence would become the fields value, I think.  I want the text field to be editable too in case minor changes need to be made.

Thank you for replying

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 ,
Sep 28, 2017 Sep 28, 2017

OK. As the custom validation script of the drop-down you can use something like this, then:

if (event.value=="Sound") this.getField("Text1").value = "indicator for high knowledge"; // etc.

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 ,
Sep 28, 2017 Sep 28, 2017

Thanks for reply but the code did not work for me. I was unable to get it to put any text into the text 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
Community Expert ,
Sep 28, 2017 Sep 28, 2017

You're probably doing something wrong... Can you 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 ,
Sep 28, 2017 Sep 28, 2017

report template.pdf - Google Drive

Here is the template I am trying to work with. I want the dropdown in the achievement column to populate the text box underneath.

Thanks for 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
Community Beginner ,
Mar 12, 2018 Mar 12, 2018

Hello!  I used to create forms in Livecycle Designer 7.... Don't laugh! It actually worked pretty decently.   Anyway, I no longer have that program and Acrobat cannot edit the PDFs created with Livecycle so I'm creating forms all over again as a form needs to be updated.  My question tacks onto the end of the one you replied to.... but I have an additional question.  I used the string of code you gave:

if (event.value=="Sound") this.getField("Text1").value = "indicator for high knowledge"; // etc.

and altered it to match my field's names.  It (obviously) works.  My question is... is there a character that can be used to send text to a 2nd/3rd/4/th line? 

When I select "Wilmington" in my combo box, I want the text box to be filled like this:

business name

address 1

city, state, zip

phone number

fax number

If I simply type all the info in where you have "indicator for high knowledge" then the text field is filled with the info all on one line like so:

business name address 1 city, state, zip phone number fax number

Thoughts??

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 ,
Mar 12, 2018 Mar 12, 2018

Use "\n" to add a line-break in the middle of a string, like this:

"business name\naddress 1\ncity, state, zip\nphone number\nfax number"

Of course, you have to set the field as being Multiline for it to display correctly.

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 Beginner ,
Mar 13, 2018 Mar 13, 2018
LATEST

Perfect!  Thank you! 

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 ,
Sep 28, 2017 Sep 28, 2017

See this great (and free) sample, data and JavaScript are all in the dropdown :

http://abracadabrapdf.net/parking/AcroUsers/Populate-text-field-from-dropdown.pdf


Acrobate du PDF, InDesigner et Photoshopographe
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 ,
Sep 28, 2017 Sep 28, 2017

when i try this code It just copies the choice from the dropdown into the text field. E.g if I select sound it will put sound into the text field. How do i edit the sentences?

Thank you

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 ,
Sep 28, 2017 Sep 28, 2017

I worked it out. Thank you so much for code. Is there anyway for there to be multiple lines of text in the one textfield from several different dropdown selections?

Thank you

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