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

Dynamic DropDown List Add - Delete items

Enthusiast ,
Nov 24, 2017 Nov 24, 2017

Copy link to clipboard

Copied

Hi Great Developers...

Actually I Started building form (Acrobat Pro DC)  and adding Drop down list and i need to dynamically let the user to add list of emails manually so i insert (Add Button) and (Delete Button) to Add items or delete items to list, for the Adding items Button i wrote the following  (my drop down list name is "EmailList" :

Add Button JavaScript  (not working) :

var oFld = this.getField("EmailList");

var cEntry = oFld.getItemAt(oFld.currentValueIndices,false);

oFld.insertItemAt(cEntry , "s", 0);

and for Delete items Button JavaScript (working code) :

var f = this.getField("EmailList");

f.deleteItemAt(f.currentValueIndices);

now the problem is the Add Button JavaScript is not Working! , please help me if it can be done, thanks in advance

Best
Mohammad Hasanin
TOPICS
Acrobat SDK and JavaScript , Windows

Views

2.0K

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

correct answers 1 Correct answer

Enthusiast , Nov 25, 2017 Nov 25, 2017

Thank you for your reply, i succeed in modifying the code so it becomes :

for Adding to dropdown menu from text field it will be :

//Add current email to DropDown list

var emailvalue = this.getField("emailbyuser").value;

var f = this.getField("EmailList");

f.insertItemAt(emailvalue , "", 0);

and for deleting the selected value from dropdown menu it will be :

//Delete current selected value from emaillist

var f = this.getField("EmailList");

f.deleteItemAt(f.currentValueIndices);

Votes

Translate

Translate
Community Expert ,
Nov 24, 2017 Nov 24, 2017

Copy link to clipboard

Copied

You're add script isn't adding anything new to the list. It looks like it is trying to move an existing item to the top of the list.

Here's an article that includes a sample file with a button for adding an item to a list, from another list. In your case you might want this to be from a form field, but the script will be almost exactly the same.

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
Enthusiast ,
Nov 25, 2017 Nov 25, 2017

Copy link to clipboard

Copied

LATEST

Thank you for your reply, i succeed in modifying the code so it becomes :

for Adding to dropdown menu from text field it will be :

//Add current email to DropDown list

var emailvalue = this.getField("emailbyuser").value;

var f = this.getField("EmailList");

f.insertItemAt(emailvalue , "", 0);

and for deleting the selected value from dropdown menu it will be :

//Delete current selected value from emaillist

var f = this.getField("EmailList");

f.deleteItemAt(f.currentValueIndices);

Best
Mohammad Hasanin

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