Skip to main content
abdallam73011229
Known Participant
January 13, 2022
Answered

how to add item and value to dropdown list

  • January 13, 2022
  • 2 replies
  • 1308 views

i make a secuired pdf file and want to let the company to add the pilot names as (values) and their IDs as (items) in the dropdown list, without reaching to my script.

i use this script:

function PopulateCabinCrewCode()

{ for (var i=10; i<20; i++) { this.getField("code" + i).setItems([

["", ""],

["41", "I.Amer "],

["46", "M.Mokhtar"]

]); } }

 

thanks in advance.

This topic has been closed for replies.
Correct answer Thom Parker

Read this article and download the example script:

https://acrobatusers.com/tutorials/list_and_combo_in_lc/

 

While the article is about copying data between lists. It shows how individual items can be added and removed from a list. 

You'll find general information about scripting lists here:

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

 

And another list programming sample here:

https://www.pdfscripting.com/public/Free-Sample-PDF-Files-with-scripts.cfm

 

 

2 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 13, 2022

Read this article and download the example script:

https://acrobatusers.com/tutorials/list_and_combo_in_lc/

 

While the article is about copying data between lists. It shows how individual items can be added and removed from a list. 

You'll find general information about scripting lists here:

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

 

And another list programming sample here:

https://www.pdfscripting.com/public/Free-Sample-PDF-Files-with-scripts.cfm

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
JR Boulay
Community Expert
Community Expert
January 13, 2022

You can place items and values in a CSV file placed as an attachment in the PDF.

So your client just need to edit/replace the CSV file to update the dropdown.

Acrobate du PDF, InDesigner et Photoshopographe
abdallam73011229
Known Participant
January 13, 2022

 how to make CSV file placed as an attachment in the PDF ?

BarlaeDC
Community Expert
Community Expert
January 13, 2022

Hi,

 

A CSV file is just a file which contains items seperated by comma (or tabs) and each row is an entry

 

firstname, secondname

Bob, Marley,

Frank, Beard,

 

And you can attach it to a PDF searching for attach. and selecting "Attach File"

Then you would need to change your code to read the values from the CSV File.

 

You can get all attachements using

//taken from AcrobatDC_js_api_reference.pdf
var d = this.dataObjects;
for (var i = 0; i < d.length; i++)
console.println("Data Object[" + i + "]=" + d[i].name);