Skip to main content
Participant
June 25, 2018
Answered

I want to create an dropdown list that contains contingent/dynamic values.

  • June 25, 2018
  • 1 reply
  • 650 views

I want to create a PDF that provides either content (text) or options contingent on the value chosen in a previous field.

1. First question; does this sound doable with javascript. 

For purposes of question one; here is a simple example

Assume a form with 2 fields; Size and Color.

For size, there are two options in a dropdown; "small" and "large"

If the user selects "small", then text options for color would be "red" and "green".

If the user selects "large", then text options for color would be  "black" and "white".

2. Where would one find documentation on the methods  available for Javascript within Acrobat. Or any documentation, for that matter?

This topic has been closed for replies.
Correct answer try67

1. Yes, this can be achieved using a script.

Here's the code for your example. It should be used as the custom validation script of the "Size" field:

var colorField = this.getField("Color");

if (event.value=="small") colorField.setItems(["red", "green"]);

else if (event.value=="large") colorField.setItems(["black", "white"]);

2. Here: Adobe - Acrobat Developer Center | Adobe Developer Connection

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 25, 2018

1. Yes, this can be achieved using a script.

Here's the code for your example. It should be used as the custom validation script of the "Size" field:

var colorField = this.getField("Color");

if (event.value=="small") colorField.setItems(["red", "green"]);

else if (event.value=="large") colorField.setItems(["black", "white"]);

2. Here: Adobe - Acrobat Developer Center | Adobe Developer Connection

TMWagnerAuthor
Participant
June 25, 2018

Thank you for the direction. That will definitely get me headed the right way.

Another question:  The example I gave was a simplified version of what I really want to do (close enough though, that I can get it to work). However, with more complexity - would it be advisable to develop within Indesign and export to PDF?

try67
Community Expert
Community Expert
June 25, 2018

No. In fact, I would recommend doing all the fields work in Acrobat, including scripts.