PDF Forms Multi-selection Popup Menu
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!
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
Copy link to clipboard
Copied
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();
}
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
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?

