Skip to main content
Participant
August 9, 2023
Question

Populate Dropdown options from textfield

  • August 9, 2023
  • 1 reply
  • 337 views

Hello, 

Im trying to have a dropdown menus options be populated based on the input in two other textfields

 

ex: I have a textfield named "buyerName1" and another named "buyerName2". I would like to have what is inputed into those two fields be the only 2 options available when you click on the dropdown field. This seems like it should be reletively simple but im having trouble finding a guide for it and im very new to Adobe. 

 

Thank you for any help you can provide!

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
August 9, 2023

Try this as custom calculation script of dropdown field:

var b1 = this.getField("buyerName1").valueAsString;
var b2 = this.getField("buyerName2").valueAsString;
var drop = [];
if (event.source && (event.source.name=="buyerName1" || event.source.name=="buyerName2")) {
 if(b1)drop.push(b1);
 if(b2)drop.push(b2);
 if(drop.length !== 0)
 event.target.setItems(drop);
 else
 event.target.clearItems();}
Participant
August 10, 2023

Thank you for the responce! I wasnt able to make this work but that might vary well be my fault.

I set this up under "Actions", Select trigger as "Mouse down", Select action as "Run JavaScript" and then copy and pasted the exact script you placed above. When I go to the sign section and click on the dropdown box all I get is a ding and nothing else. I also exported the PDF and tried it in another PDF application with the same result. Should I have placed this in a different area or restructed the script itself?

 

I do really appreciate the help as I have extremely limited experience with both Adobe and Javascript 🥹

Nesa Nurani
Community Expert
Community Expert
August 10, 2023

As I wrote in my previous post, use it as 'custom calculation script' of dropdown field.