These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Loading items in a dialog edit_text popUpEdit drop down list

AndrewAlb
Registered: Aug 16 2007
Posts: 97
Answered

Hello,
I am having difficulty determining how I load option elements into an edit_text popUpEdit dialog text field.

this is an edit_text element of the dialog object that has its popUpEdit property marked, true.

It seems to me like this should be a combo-box.

I have my dialog working fine, I have the drop down list appearing, I just can't load any items into it?

I have tried using an object of elements like you do for the list list_box object:

dialog.load({"conv":{"item1":1, "item2":2, "item3":3}});

I have tried using an array like so:

dialog.load({"conv":["item1","item2","item3"]});

but I can't seem to get anything to work...There doesn't seem to be anything written about this for this purpose - though I can't see what else you would use it for.

Any help would be appreciated.

Thank you.
-Andrew

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Have you reviewed the examples 3 and 4 under the "app.execDialog" method?

Example 3 snippet:
dialog.load({
subl:
{
"Acrobat Professional": +1,
"Acrobat Standard": -2,
"Adobe Reader": -3
}
})
},Yours:
dialog.load({"conv":{"item1":1, "item2":2, "item3":3}});

and:
dialog.load({"conv":["item1","item2","item3"]});

Suggested:
dialog.load({
conv:
{
"item1": 1,
"item2": 2,
"item3": 3
}
})
},

George Kaiser

AndrewAlb
Registered: Aug 16 2007
Posts: 97
Thanks for your response,

Unfortunately I did actually try that (essentially removing the quotes from the element name correct?) - However, still no luck.

I can't understand why this isn't documented if it is in fact different than the list box?

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1876
Are you calling that in the "initialize" handler? Also, the item values should be negative if you don't want them selected by default. You may want to post all of the code you're using.

George
AndrewAlb
Registered: Aug 16 2007
Posts: 97
George, thanks for your thoughts - I am in fact calling it in the initializer handler.

I have posted a truncated version of the code (these dialogs get really big as I am sure you know).

Thanks again for all your help, especially for the insight regarding the negative numbers - I didn't know that. I was hoping that might have been it, but no.

You can run this from the console to see what is going on if you like.

//Begin code

var dialogResults;
var dialog = {

initialize: function(dialog) {

dialog.load({
conv:{
"ING" : -1,
"Ebix" : -2,
"Affirm" : -3
}
}
)
},

commit: function(dialog) {
dialogResults = dialog.store();
},

description: {

name: "Tool Menu Options",
elements:
[
{ //main dialog grouping
type: "view",
align_children: "align_left",
elements:
[
{ // dialog title
type: "static_text",
name: "Tool Menu Options",
char_width: 30,
height: 20,
alignment: "align_center"
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "Naming Convention:",
},
{
type: "edit_text",
item_id: "conv",
PopupEdit: true,
width: 200,
height: 20
}
]
},
{
type: "ok_cancel",
}
]
}
]
}
}

app.execDialog(dialog);

// End code

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
AndrewAlb wrote:
Thanks for your response,Unfortunately I did actually try that (essentially removing the quotes from the element name correct?) - However, still no luck.

I can't understand why this isn't documented if it is in fact different than the list box?
Not only were the quote marks removed, but the ';' was replaced with a coma. A semi colon denotes the end of a statement and according the specifications you need to use a coma.

Have you looked at the JavaScript console for any error messages?

You might want to look at [url=http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/]The Acrobat JavaScript Console (Your best friend for developing Acrobat JavaScript)[/url] by Thop Parker.

George Kaiser

AndrewAlb
Registered: Aug 16 2007
Posts: 97
Ah right - I didn't see the semi colon.
I tried that as well - however still no luck.

Thanks for the tip about the the console. I am actually pretty familiar with it and I am not getting any errors with my script - it just appears to be ignoring it altogether.

Thanks though.

-Andrew

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You also need to use the right element type of element for the list box.

Your code that reads:
{type: "edit_text",item_id: "conv",PopupEdit: true,width: 200,height: 20}

Should read:
{type: "list_box",item_id: "conv",width: 200,height: 20}

George Kaiser

AndrewAlb
Registered: Aug 16 2007
Posts: 97
George, thanks again for your thoughts.

I guess I will be forced to go with the list_box element.

I was really hoping however to find how to use that PopupEdit property option in the edit_text element.

It seemed to me that this was the way to make it a combo box - which is really what I want.

Oh well - the list box works.

I will leave this post open however, just in case anyone stumbles upon that does know how to use the PopupEdit property.

Thanks again to both of you.
-Andrew

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

sdavenhall
Registered: Aug 29 2008
Posts: 1
This will create your combo box:

var myDialog =
{initialize: function(dialog)
{// Set up and store the values in list_box sub1:
dialog.load({


"sub1":
{
// Note: positive value represents the selected item
"one": -1,
"two": -2,
"three": +3, // currently selected item
"four": -4
}
});
},


commit: function(dialog)
{
// Retrieve the values stored in list_box sub1:
var elements = dialog.store();
// Iterate through items and take actions as needed
for (var e in elements["sub1"])
// If the value is positive, it was selected:
if (elements["sub1"][e] > 0)
{
// display the list value selected:
app.alert("You chose:\n" + elements["sub1"][e]);
// call a related function for the selection
rc = elements["sub1"][e];
ListHandler(rc);
}
},


// Dialog object descriptor (root node)
description:
{
name: "Sample Dialog",
elements:
[
{
type: "view",
align_children: "align_left",
elements:
[
{
type: "cluster",
name: "Provider",
elements:
[
{
type: "static_text",
name: "Select Item",
font: "default"
},
{
type: "popup",
item_id: "sub1",
variable_Name: "sub1",
width: 100,
height: 20
},
{
type: "ok_cancel"
}
]
}
]
}
]
}
};


// Function to handle the user’s list selection:
function ListHandler(sub1)
{
switch (rc) {
case 0:
app.alert("ListHandler response for 1 - one");
break;
case 1:
app.alert("ListHandler response for 1 - one");
break;
case 2:
app.alert("ListHandler response for 2 - two");
break;
case 3:
app.alert("ListHandler response for 3 - three");
break;
case 4:
app.alert("ListHandler response for 4 - four");
break;
default:
app.alert("Invalid selection: " + rc);
break;
}
}
rc = app.execDialog(myDialog);
AndrewAlb
Registered: Aug 16 2007
Posts: 97
sdavenhall - thank you very much for that.
I was so focused on the PopupEdit property of the edit text element - that I completely missed that popup was a type itself.

Thanks again!

Andrew D. Albrecht, MS
Solutions Developer
ING USFS

mmazal
Registered: Jul 20 2009
Posts: 27
I know this is an old thread but along the same lines...

if I ititialize the popup with

dialog.load({"mth1":
{
"Jan":+1,
"Feb":-2,
"Mar":-3,
"Apr":-4,
"May":-5,
"Jun":-6,
"Jul":-7,
"Aug":-8,
"Sep":-9,
"Oct":-10,
"Nov":-11,
"Dec":-12
}
});

The popup for some reason sorts the months in alpha order "Apr, Aug, Dec..."

How do I make it stop doing that?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
(Old thread, I know, but my question is relevant...)

Any one had any luck in injecting the values of the list box items as variables into the dialog instead of hard-coding them?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

mmazal
Registered: Jul 20 2009
Posts: 27
Figured my thing out all by myself (sort of)
Had to label the months as "01 Jan" then "02 Feb" to keep them in the order I wanted.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I wish I would have seen this thread earlier. I've done a great deal with JavaScript dialogs.
I use exactly the same solution you've figured out for listing items in a specific order. I use a ":" to separate the number from the month/item name so it can be easily parsed using the split() function.

Lists always arrange the elements with a lexical sort. The export number on each item does nothing except select the currently displayed item.

You might want to check out AcroDialogs. There's a free trial. It creates correct dialog code so you can see the details of how it all works.

http://www.windjack.com/products/acrodialogs.php

You'll also find working examples of Acrobat automation tools that use JavaScript dialogs here:
http://www.pdfscripting.com/public/65.cfm

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Hi Thom,

Any chance you have an answer to my question above?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, I do have an answer. You cannot set the items in a list to a variable, at least not directly. What you can do is rebuild the list using the dialog.load() function. You can do this at any time while the dialog is running. Usually you'll do this from the action event on another dialog control like a check box or another list. But I've also done some funky stuff from outside the dialog, such as a timer script that was started from the dialog's initialize event.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Hmmm... I guess I'll need to experiment with that some more.
Do you have an example, perhaps? Anyway, thanks for the tip.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Loading the list is done in exactly the same way whether it's in the initialize event or any other event. For example, if you had a radio button with the id "rad2". Then the entry in the dialog object literal would look like this:

"rad2":function(dialog){
dialog.load({"lst1":{apples:-1,oranges:-1,grapes:-1}});
},

Whenever "rad2" is pressed, "lst1" is loaded with 3 entries.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

try67
Expert
Registered: Oct 30 2008
Posts: 2398
I think you misunderstood me.
I know how to load the list with literal values. What I want to do is load it with values kept in variables created outside of the dialog, something like this:

var fruit1 = "apples";var fruit2 = "oranges";var fruit3 = "grapes"; var dialog = {// ... now load fruit1,2,3 into a list box in this dialog.}

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Use the Object array notation
var fruit1 = "apples";var fruit2 = "oranges";var fruit3 = "grapes"; var dialog = {initialize: function(dialog){var myList = {};myList[fruit1] = -1;myList[fruit2] = -1;myList[fruit3] = -1;dialog.load({"lst1":myList});}, }

You could also use string operators and the eval() function to do some really clever and compact code. But using the array notation is the simplest and most straight forward method.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Cheers, I'll give that a go. I was about to use the eval() route, but thought there might be a better way to do it.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com