Highlighted

HELP! Trying to use two drop down boxes together

New Here ,
Sep 04, 2020

Copy link to clipboard

Copied

Hi,

I am new to using adobe and I am trying to make two drop down boxes work together. What I need is for the selected item in either drop down to populate the other drop down with the corresponding selection and vice versa. I have been able to make the two separate drop down boxes and put all list items in their respective boxes, but I have no idea how to make the two correspond with eachother. Any help would be much appreciated.

Thanks!

Running Acrobat Pro DC 

TOPICS
Create PDFs, Edit and convert PDFs, How to

Views

111

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

HELP! Trying to use two drop down boxes together

New Here ,
Sep 04, 2020

Copy link to clipboard

Copied

Hi,

I am new to using adobe and I am trying to make two drop down boxes work together. What I need is for the selected item in either drop down to populate the other drop down with the corresponding selection and vice versa. I have been able to make the two separate drop down boxes and put all list items in their respective boxes, but I have no idea how to make the two correspond with eachother. Any help would be much appreciated.

Thanks!

Running Acrobat Pro DC 

TOPICS
Create PDFs, Edit and convert PDFs, How to

Views

112

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 04, 2020 0
Contributor ,
Sep 04, 2020

Copy link to clipboard

Copied

That doesn't sound to hard to do, but you need to be little more specific. You want it to populate or show specific selection?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 04, 2020 1
New Here ,
Sep 04, 2020

Copy link to clipboard

Copied

I think I want it to show specific selection. I'm not exactly sure. Basically I need the item in either of the selected drop downs to correspond with one another.   I'm making a parts list, one drop down will have part numbers and the other with part descriptions.  Not all my employees will know part numbers or part descriptions but, they will know one or the other, so the drop down selections needs to link together on whatever they select.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 04, 2020 0
Engaged ,
Sep 04, 2020

Copy link to clipboard

Copied

In 'Format' tab select 'custom' and then 'Custom format script' and use code below.
In my example if you select first option in dropdown1 it will select 3rd option in second dropdown or if you select option 2 it will select option 1 in second field. Since I don't know what options you will be linking,  you will have to adapt code to your needs.


if (!event.willCommit){
var sel = event.changeEx;
var f = this.getField("Dropdown2");

if (sel == "Selection1"){
f.value = "Selection3";}

else if (sel == "Selection2"){
f.value = "Selection1";}

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 04, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

So, I've tried adding this code to Dropdown1 and nothing happens. Tried adding it to Dropdown2, still noting. Tried both dropdowns, again, nothing. I'm not getting a syntax error of any kind but no matter what configuration I try, I still get no change when selecting an item from either dropdown box.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Engaged ,
Sep 10, 2020

Copy link to clipboard

Copied

Sorry about that I mistyped, put the code in "Custom Keystroke Script"

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

Just tried the same all the same things, but added the code to the "Custom Keystroke Script" box. Still nothing happening.

 

Would it help if mention that what i need to happen is, lets say, both dropdown boxes have different lists numbered one item at a time 1-100. I need to be able to pick 1-100 in either dropdown and have it put the corresponding 1-100 in the other.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Contributor ,
Sep 10, 2020

Copy link to clipboard

Copied

You should have said that from the start. Nesa's code is working but you need to adapt it to your values, change selection 1 to 1 selection2 to 2...etc also it would be good to use loop to go through values so you don't have to write long code, but like I said you should write from start all info.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

The problem I'm having is not knowing exactly how to ask what it is that i need done. Is there any way I can attach my form for one of you to review? So maybe I will be better able to describe what I need it to do. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Contributor ,
Sep 10, 2020

Copy link to clipboard

Copied

You can upload it to google drive or dropbox... and post link here

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

The two dropdowns I'm working with are "Dropdown1" under the Part# and "Dropdown2" under the Description.  The listed items in each dropdown coincide with each other in descending order. ie: BAR 1202 in Dropdown1 and 3/8" x 8' whip line 4500 PSI in Dropdown2.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Engaged ,
Sep 10, 2020

Copy link to clipboard

Copied

If I got it right hopefully, it's easy to do but it will take you long since you didn't give export values to your selections. Just go to "Dropdown2" and in calculate tab select "Value is the" and pick "Dropdown1". Now for the hard part give all your selections in both fields export values, for example:

in "Dropdown1" selection "John" export value 1 in "Dropdown2" selection "Doe" export value also 1. now when you select "John" from "Dropdown1","Dropdown2" will show "Doe" you need to add values like that for all your selections. Give same values to two selections that you want to pair. Hope that is what you looking for.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

Do I still need to add the "Custom Keystroke Script" code? Then make the changes you've said to the export values?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Engaged ,
Sep 10, 2020

Copy link to clipboard

Copied

You can also use this code in "Dropdown2" custom calculation script instead of "value is the"

if(event.value = this.getField("Dropdown1").value);
else event.value = "";

 

Here is your file, I changed first 5 selections for you to test ( you will need to do rest of them)

https://drive.google.com/uc?export=download&id=1B8IS7G9ujAduzavSoJ_rj3KMks6mblvw 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Engaged ,
Sep 10, 2020

Copy link to clipboard

Copied

You don't need Custom keystroke code I posted above.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

Nesa, 

Thank you! That's what I was looking for! One more question on this topic, though I have many more related to this project, How do I make Dropdown2 autofill Dropdown1 like you did with 1 and 2?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Contributor ,
Sep 10, 2020

Copy link to clipboard

Copied

You just want dropdown 2 to fill dropdown1, or you want at the same time if you select dropdown1 fill dropdown2 or if you select dropdown2 fill dropdown1?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

Yes, I want to be able to select dropdow1 to fill dropdown2 and dropdown2 to fill dropdown1.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 11, 2020 0
Adobe Community Professional ,
Sep 10, 2020

Copy link to clipboard

Copied

In order to do what you are asking requires a method for mapping the entries in one list to the entries in the other list. The script that does this could be a format, validate, or keystroke script. This part really isn't imporant. The important bit is to have method for mapping the entries between the lists. 

 

There are several ways this can be done. One method is to hard code the mapping in the script itself, as suggested by Nesa. However, I prefer to go with a more generic approach. Make the data embody the mapping.  For example, in the first list, the main entry text is the part number and the export value is the description. Then in the second list the main entry text is the descripting and the export value is the part number. Now all the script needs to do is set the other field to the display (main) value of current field. The scripts on both dropdowns are identical, only the data is different. 

 

Another approach is to use a generic object to contain the lists and map the values.

Like this:  var oList = {"1155AB":"The small part", "2255CD":"The Large Part"};

 

Then the script sets the other dropdown according  values in the object. The advantage of this approach is that this object can also be used to populate the dropdowns, so you have a automated path to updating the part list that stems from a single source, i.e., the list object.  This method can be easily combined with the first one I described. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

Thom, 

Most of this is a little over my head but I'm willing to try. I really like the way you said to use a generic object to contain the lists, but I have no idea how to execute any of that.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Adobe Community Professional ,
Sep 10, 2020

Copy link to clipboard

Copied

There are 3 parts to using the method I described. And it takes some scripting chops.

 

1)  Create the Parts list in a document script.

var oList = {"1155AB":"The small part", "2255CD":"The Large Part"};

 

2) Create a function for populating the fields, also at document level. Since you have several dropdowns. I would suggest using group naming

So "PartNum.Row1", "PartNum.Row2", etc.   "PartDesc.Row1", "PartDesc.Row2", etc.

This makes it much easier to create loops for setting lists to the fields.

 

Do not call this function in the document script, just define it. You'll only need to call it when the lists need to be loaded. So do this part manually from the console window.

 

I'd set this up so that the export value for both lists is the part number. 

 

3) Use a Keystroke script to set the value in the other field.

    Like this

 

if(!event.willCommit)

{// Get field name for other field first.

    cListName = "PartDesc." + event.targetName.split(".").pop();

    this.getField(cListName).value = event.changeEx;

}

 

Notice how the field name for the other list field on the same row is built from part of the name from the current field. This assumes the field naming I proposed. 

      

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2020 0
Adobe Community Professional ,
Sep 11, 2020

Copy link to clipboard

Copied

The keystroke script (in part 3) above will provide exactly the functionality you want. 

However, it depends on the export value of the entries in the lists being the same for both fields. 

 

To do this, do not fill out the "export" value for the part number list. The export value defaults to the display value, if its not specified. But for the description list, use the part number as the export value. 

 

This will solve your first issue. But you have others. There are several lines of these fields on the form. You need a methodology that will allow you to quickly update the lists if something changes. You also need to be able to easily add the scripts to all of those fields. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 11, 2020 0
New Here ,
Sep 15, 2020

Copy link to clipboard

Copied

Thom,

I was able to make the var oList in part one, but I'm pretty clueless on how to do part 2. Example? Help?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2020 0
Adobe Community Professional ,
Sep 15, 2020

Copy link to clipboard

Copied

The items in a List (dropdown) field are set with the "field.setItems()" function. Here's the reference entry. 

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

The input to this function is an array of list field entries, so the trick is to get all the values in the Part List Object (Part 1) into an array.

 

You can find out all about programming Acrobat list fields here:

https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm

 

 Say that the field are named as I suggested in Part 2, i.e., "PartNum.Row1", "PartNum.Row2", etc.   "PartDesc.Row1", "PartDesc.Row2", etc.

 

This function will set the values in a specific row.

 

function SetPartListInRow(cRowName)
{
     var aPartNumList=[], aPartDescList=[];
     for(var nm in oList)
     {
        aPartNumList.push(nm);
        aPartDescList.push([oList[nm],nm]);
     }
     this.getField("PartNum." + cRowName).setItems(aPartNumList);
     this.getField("PartDesc." + cRowName).setItems(aPartDescList);
}

 

To use this function, Open the console window and run this code

 

SetPartsListInRow("Row1");

 

Now the list fields in the first row will be setup with the correct list values. When you need to make an update, change the list in the document script and then rerun this function. Much faster, easier, and more reliable, than manually updates the lists.

 

You could improve this function by added code for looping over all the rows and by automatically adding the custom keystroke scripts. So you never have to edit the actual fields. It's all done automatically from this setup function.  

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2020 0