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

Dropdown field with 6 choices with same few fields and different text

New Here ,
Apr 08, 2019 Apr 08, 2019

[Title edited for brevity by moderator. Was:

”Hi all I am looking to have several fields displayed on condition of a dropdown field. The dropdown field has 6 choices and for every choice the same few fields on the form will contain different text.”

Hi you clever guys and girls out there, this is the first time I have ever posted on a forum so be gentle with me. I am trying to create a form with about 8 smart fields that will contain different text depending on the selection of a drop down box

I have a rough idea of what I need to create but absolutely no idea how to go about it eg:

the field that I need to deposit the text in i create some script which goes along the lines of:

getField (the conditional drop down box)

     if this == (my condition 1)

     display("special text for condition 1")

I have no idea how to make this work using JS

any help much appreciated

steamboy

TOPICS
PDF forms
828
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
1 ACCEPTED SOLUTION
Community Expert ,
Apr 09, 2019 Apr 09, 2019
LATEST

You're welcome!

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

View solution in original post

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
People's Champ ,
Apr 08, 2019 Apr 08, 2019

There are many ways to skin a cat, but I would do something like this:

var o = {

"Apples": "Big and red",

"Oranges": "Round and sweet",

"Pears": "Like apples"

}

this.getField("Text Field 1").value = o[event.value];

Hopefully you follow, but to spell it out, the salient points are as follows:

We've set up an object o that has a list of key pairs, so o["apples"] returns "Big and red" etc.

In the last line, we get a reference to the text field into which you want to place the text (using its name, which for the sake of the example is "Text Field 1"), and look up the o object to get the text you want to copy.

So, modify as needed.

To use, select the dropdown field and insert the script as a custom validation script.

HTH,

Ariel

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
People's Champ ,
Apr 08, 2019 Apr 08, 2019

The fact is that dropdown lists have a value called "Export value" which is accessible under the Options tab of the Dropdown Properties dialog box in Acrobat. So you could feed in the desired values there, and get the script to extract those.

The problem with that approach is that you have to fiddle about with Acrobat's awkward UI and type in the export values there.

I think it's just much easier to use your favourite text editor to type in the values as an object and have everything self-contained in the script...

If you'll be referring to o repeatedly in the form, you may want to create o as a global object (by inserting it as a document-level 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 09, 2019 Apr 09, 2019

Wow! thanks very much for giving me a solution that I can build on. I think I get it. I will let you know when the final form is created.

Thank you so much TaW

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 08, 2019 Apr 08, 2019

Here are two articles that discuss doing this exact thing, and they have samples:

https://acrobatusers.com/tutorials/change_another_field

https://acrobatusers.com/tutorials/show_hide_fields

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 09, 2019 Apr 09, 2019

Hi Thom

Thanks for sending a reply to my question, these are just the Tutorials that I have been looking for.

Cheers

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 09, 2019 Apr 09, 2019
LATEST

You're welcome!

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