• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to add item to drop-down list using javascript?

New Here ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

I added button to my pdf and when I clicked to button, it added a textarea dynamically.

So I want to keep these names on drop-down list but I cannot add item dynamically to drop-down in javascript.

 

I wrote like this;

this.getField("list").setItems(["CustomItem" + count]);

but this code added only one item.

TOPICS
Acrobat SDK and JavaScript

Views

6.7K

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
community guidelines
Community Expert ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

Try this:

this.getField("list").setItems(["CustomItem1" + count, "CustomItem2" + count, "CustomItem3" + count ]);

Votes

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
community guidelines
New Here ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

Thank you for answer.

 

But I added dynamically. New control is adding when I click to a button.

So I must add a new item to old items.

 

For example first click I want to add new item control1,

second click, add new item control2.

Votes

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
community guidelines
Community Expert ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

You must use a list. Read the items of the dropdown, create a list of this items, and add the new entry. Then use the method setItems with this list.

You can also use the method insertItemAt.

Votes

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
community guidelines
New Here ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

Thank you.

I thought this way but cannot find anything how can I get this list in JS.

Votes

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
community guidelines
Community Expert ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

To read the entries you can use the method getItemAt.

Votes

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
community guidelines
Community Expert ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

LATEST

Here's an article on how to add and remove items from a list and/or dropdown. And there is a sample file.

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

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines