Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


PDF Forms Multi-selection Popup Menu

New Here ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

Hello, I'll start with im semi - experienced in code and designed a popup menu that you select "English" "Spanish" "French" and it places the option selected in the text filled. Although I am having difficulties making the pop up mark each selection and multi selecting them into the text filled like this "English, Spanish, French" if you were to select multiple. The code I have now is as follows, with the text fill being "Languages":

var cRtn = app.popUpMenuEx({cName:"English"},{cName:"Spanish"},{cName:"-"},{cName:"German"},{cName:"Japanese"});

if(cRtn) this.getField("Languages").value = cRtn;

Any tips or help would be greatly appreciated thanks!

TOPICS
General troubleshooting, JavaScript, PDF forms

Views

252

Likes

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
Adobe Community Professional ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

Pop up menus don't allow multiple selections, although you could add some checkmarks and make sort of a workaround but still every time you click on selection menu would go away and it would require advance scripting, your best option is to use custom dialog boxes.

You can find here some custom dialog box examples:

http://www.windjack.com/resources/Examples/DialogUses.pdf 

 

Likes

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
Adobe Community Professional ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

LATEST

Well your code will need to be much more complex to accomplish the behavior you've described. First, you'll need a way to maintian state, i.e., which entries are currently selected. This "state" is then used to dynamically build the menu.  

 

For example, here's a pseudo code outline.

 

 

 

 

//**** At the document level

// Initialize state from data saved in hidden formfield.

var strLangStateData = this.getField("LangState").value;

var oLangState = null;

if(strLangStateData =="")

{// First time, create new state data
    oLangState  = {Spanish:false, English:false,...};
}else
    oLangSate = eval(strLangStateData);

//**** On button field
// Menu Script 
// First build menu
var aMenuItems = [];
for(var cLang in oLangSate)
     aMenuItems.push({cName:cLang, bMarked ....});

var cRtn = app.popUpMenuEx.apply(app,aMenuItems);
if(cRtn)
{// toggle State
    oLanState[cRtn] != oLanState[cRtn];

    // build result
    var strLangs = "";
    for(var cLang in oLangSate)
    {
        ... code to build languages string
    }
    this.getField("Languages").value = strLangs;
    
    // Save state data back to hidden field
    this.getField("LangState").value = oLangState.toSource();
 }

 

 

 

 

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

Likes

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