Copy link to clipboard
Copied
[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
Copy link to clipboard
Copied
You're welcome!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hi Thom
Thanks for sending a reply to my question, these are just the Tutorials that I have been looking for.
Cheers
Copy link to clipboard
Copied
You're welcome!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more