Skip to main content
Participant
April 16, 2022
Answered

Populating multiple dropdow from one array

  • April 16, 2022
  • 2 replies
  • 1645 views

Hi, i'm really new to this and i need help to populate multiple dropdow from one array

the array contain (art N° - description - price)

what i'm try do do is:

if i select from dropdown an article in automatic he show me on the same line descriptio and price all taken from array

 

So please help me

This topic has been closed for replies.
Correct answer Nesa Nurani

How many dropdown fields and are they all follow same naming (e.g. "Dropdown01"-"Dropdown010")?

It would be easier if you could share your file with us.

This is basic script to populate dropdowns from array for 3 fields in your photo:

var arr = ["Item1","Item2","Item3","Item4"];
for(var i=4; i<=6; i++)
this.getField("Dropdown0"+i).setItems(arr);

Use script at document level or from a button or directly from console.

2 replies

try67
Community Expert
Community Expert
April 17, 2022

[MODS: Please don't move questions about scripting to the Acrobat SDK forum. They should remain in the main Acrobat forum]

Participant
April 17, 2022

Sorry, there is a way to move directly my discussion to general forum or i've to write again

try67
Community Expert
Community Expert
April 18, 2022

My reply was aimed at my fellow-moderators of this forum, who started moving threads around even though it was not necessary. I don't believe you can move your own thread to another forum.

Nesa Nurani
Community Expert
Community Expert
April 17, 2022

You can use this basic script and adapt it to your needs, use as Validation script of dropdown field:

var arr = ["art N°","description","price"];
var fields = ["Unit_04","Desc_04","Price_04"];
for(var i in fields){
if(event.value == "Choice1")
this.getField(fields[i]).value = arr[i];}

 

Replace "Choice1" with your actual choice from dropdown.

Use 'else if' to add more conditions or to set fields blank if you have ' default value', don't forget to check 'Commit selected value immediately' in dropdown field -> options tab.

 

 

Participant
April 17, 2022

Tnks for your reply is working but...

i've more then 100 article to insert in any dropdown manually

and then i've also more then 100 elseif to write for any dropdown.

it's is the only way to do it ??

what i'm tring to do is to find a way to fill multiple dropdown from a single array and in case i do some change to the array all dropdown will be updated and after this when i select a specific article example n°97 from dropdown the rest of the field (price and description) are autocompiled with price 97 and description 97.

tnks in adv

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
April 18, 2022

How many dropdown fields and are they all follow same naming (e.g. "Dropdown01"-"Dropdown010")?

It would be easier if you could share your file with us.

This is basic script to populate dropdowns from array for 3 fields in your photo:

var arr = ["Item1","Item2","Item3","Item4"];
for(var i=4; i<=6; i++)
this.getField("Dropdown0"+i).setItems(arr);

Use script at document level or from a button or directly from console.