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;
Where did you place this code?
I have this code under calculate section, custom script.
It should be used as the custom validation script of the drop-down field.
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.
Go to the Properties of the drop-down field, Options tab, and tick the "Commit selected value immediately" box.
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.
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.
Everything matches, is it possible for me to upload a link to document in drop box and you take a look?
Yes. Use Dropbox, Google Drive, Adobe Cloud, etc., and post the link here.
I don't see where you placed the script...
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.
You had a bunch of issues with conflicting scripts in multiple fields. I fixed it for you in the attached file:
You should study the code and where it's placed, for future reference.
Appreciate it, I had multiple script because of the other actions I needed done for the document.
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.
Make sure you've removed all the calculation scripts from all of the fields involved.
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.
Again, you'll need to share the file.
I looked at it closely and figured out what I had wrong. Thank you again for all the help.
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?
Acrobat/Reader DC has an automatic calendar popup for any field with Date formatting.
Adobe acrobat XI pro doesn’t show it. So are you saying a person must own a subscription to adobe pro DC?
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:
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.