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

PDF Forms Multi-selection Popup Menu

New Here ,
May 24, 2021 May 24, 2021

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
1.7K
Translate
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 ,
May 24, 2021 May 24, 2021

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 

 

Translate
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 ,
May 24, 2021 May 24, 2021

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

Translate
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 Beginner ,
Apr 05, 2023 Apr 05, 2023
LATEST

this is a cool post, anyone manged to make this code work? 

capture the selectiond from the buttons  into a list or a text field?

Translate
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