-
1. Re: Can you create a XML dialog dropmenu.
John.Kordas Apr 27, 2009 5:07 PM (in response to John.Kordas)Here is an example of the xml file sitting on the C:\ drive called test.xml
<xmlElement><item>product1</item><item>product2</item><item>product3</item><item>product4< /item>
</xmlElement>The following is a simple dialog that has a dropmenu with the option of product1/product2/product3/product4. Is it possible to read the test.xml file and load the item options in the xml as the dropmenu dialog options?
Dialog example:
//Acrobat JavaScript Dialog
//Created by DialogDesigner from WindJack Solutions
var Sample1 =
{result:"cancel",
DoDialog: function(){return app.execDialog(this);},
strpop1:"",
SetListSel:function(list,path){if(path.length == 0) return;
eval("list[\""+ ((typeof path.join != "function")?path:path.join("\"][\"")) + "\"] = 1")},
GetListSel:function(oLstRslts,path){
for(var item in oLstRslts){
if( ((typeof oLstRslts[item]=="number")&&(oLstRslts[item]>0))
|| this.GetListSel(oLstRslts[item],path) )
{path.push(item);return true;}
}
return false;
},
initialize: function(dialog)
{
var listpop1 =
{
"product1": -1,
"product2": -1,
"product3": -1,
"product4": -1,
};
this.SetListSel(listpop1, this.strpop1);var dlgInit =
{
"pop1": listpop1,
};
dialog.load(dlgInit);
},
commit: function(dialog)
{
var oRslt = dialog.store();
var path = new Array();
this.strpop1 = (this.GetListSel(oRslt["pop1"],path))?path.reverse():"";
},
description:
{
name: "Sample #1",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Select",
font: "dialog",
},
{
type: "popup",
item_id: "pop1",
char_width: 8,
},
]
},
{
type: "ok_cancel",
},
]
},
]
}
};// Example Code
Sample1.strpop1 = "";
if("ok" == Sample1.DoDialog())
{console.println("pop1:" + Sample1.strpop1);
}

