Skip to main content
April 20, 2020
Answered

long list of data to auto populate on the base of drop down list

  • April 20, 2020
  • 4 replies
  • 1230 views

Hi, 

I am creating an Adobe form in Adobe DC and I am trying to auto populate the fields on the base of drop down list. The problem is that drop down list is too big. I am trying to find efficient way to create a form. So as an example I have in list following entries, i have concatenate the fields by "--" in excel.

a is suppose to be drop down list and when selected, it should autopopulate respective b, c and d fields.

a--b--c--d

aa--bb--cc--dd

aaa--bbb--ccc--dd 

and so on. I would like to have a, aa, aaa in the drop down list and b, bb, bbb in the corresponding field and same with c and d. 

By googling I got following script. 

this.getField("Dropdown1").setItems(this.getField("ListEntries").value.split(/[\"--"\r\n]+/g));

for the drop down list but I don;t know how to make it take only the first part of array. Could any one help me with it. 

Thanks

 

This topic has been closed for replies.
Correct answer Bernd Alheit

var listofArr = this.getField("ListEntries").value.split(/[\r\n]+/g);
for (var i=0; i<listofArr.length; i++) {
var splitlist = listofArr.value.split("--")[0];
this.getField("Dropdown1").insertItemAt(splitlist[i]);
}

 

Still nothing happens 😞


Use something like this:

var listofArr = this.getField("ListEntries").value.split(/[\r\n]+/g);
for (var i=0; i<listofArr.length; i++) {
  var splitlist = listofArr[i].split("--");
  this.getField("Dropdown1").insertItemAt(splitlist[0], splitlist, -1);
}

4 replies

April 22, 2020

Wow great! it works, Now I am trying to auto populate the "Text4" field based on the drop down list. I have tried doing following code:

var listofArr = this.getField("ListEntries").value.split(/[\r\n]+/g);
var dlist = this.getField("Dropdown1").value;
for (var i=0; i<listofArr.length; i++)
{ var splitlist = listofArr[i].value.split("--")[0];
var vfield = listofArr[i].value.split("--")[1];
if (splitlist == dlist)
{
this.getField("Text4").Value=vfield;
break;
}}

 

Thom Parker
Community Expert
Community Expert
April 20, 2020

You could use a popup menu instead of a dropdown. This allow you to have a hierachical list setup. 

https://www.pdfscripting.com/public/Creating-Popup-Menus.cfm

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
April 20, 2020

I've developed a (paid-for) tool that allows you to create such "cascading" drop-down fields automatically, based on a spreadsheet that contains all the data. You can find it here: http://try67.blogspot.com/2014/11/acrobat-create-cascading-dropdowns.html

Bernd Alheit
Community Expert
Community Expert
April 20, 2020

What want you show in the dropdown list?

April 20, 2020

Hi , 

 

In the dropdown list the first part of array should appear. Means a, aa, aaa. .... 

Bernd Alheit
Community Expert
Community Expert
April 20, 2020

With

this.getField("ListEntries").value.split(/[\r\n]+/g));

you get an array of all entries.

With a loop over this array you can extract the first part of the entries.