Skip to main content
This topic has been closed for replies.

3 replies

Aituns
AitunsAuthor
Participating Frequently
September 20, 2018

Change export value of an existing entry.

Thom Parker
Community Expert
Community Expert
September 20, 2018

There is no single function for setting a list item value, so assuming the item index is known, the script will need to acquire the current item "Name", delete the item, and then insert the new item using the acquired name and index.

Here's an example, it replaced the export value of the currently selected item.  The script is written for a button. You should run it first from the console window to make sure it works.

var cNewVal = this.getField("TextField").valueAsString();

var oListField = this.getField("ListField");

if(oNewValue.length)

{

    var nIdx = oListField.currentValueIndices[0];

    var strName = oListField.getItemAt(nIdx,false);

    oListField.deleteItemAt(nIdx);

     oListField.insertItemAt(strName,cNewVal,nIdx);

}

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Aituns
AitunsAuthor
Participating Frequently
September 25, 2018

I'm not sure if i understand this. I am very new to adobe and coding.

Aituns
AitunsAuthor
Participating Frequently
September 20, 2018

What I am trying to do is when you enter your email in a form a the end of the PDF there is a submit button and drop-down list that emails based on the selection. And this would get the email that you entered and sticks it into one of the export values of one of the selections on the drop down list.

Thom Parker
Community Expert
Community Expert
September 20, 2018

So you want to add entries to a list?  Or change the export value of an existing entry?

The article I linked provides a perfect example for adding emails to a list.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
September 20, 2018

Yes, here is an article on programming list/dropdown fields

https://acrobatusers.com/tutorials/list_and_combo_in_lc

However, this may not be a very practical solution.  What is it that you are trying to do? 

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