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

Dialog Load List Box Default Value

srprice
Registered: Sep 19 2007
Posts: 138
Answered

Is it possible remove the default value set on a List_Box? I have created a script that populates a list box from field values within a form but need to unselect the default value.

Here is a snippet of the code:

var a = this.getField("ESD_K_1").value;
var b = this.getField("ESD_K_2").value;
var c = this.getField("ESD_K_3").value;

var n = new Object();
n[a]=1;
n[b]=2;
n

=3;
 
var myDialog = 
 
{
initialize: function(dialog)
{
  dialog.load({"sub1":n});
 
 },
 
Thanks in advance for your help.
 
Sarah

My Product Information:
Acrobat Pro 8.1.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
the selected item in a custom dialog list is indicated by a positive number. You've set all you entries to be positive. This is incorrect. Only set one to a positive number, or if you don't want any selection make them all negative.

Like this:

var n = {};
n[a]=-1;
n[b]=-2;
n
=-3; This will create a list with no selections.

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

srprice
Registered: Sep 19 2007
Posts: 138
Thank you so much. I knew was something simple I was missing.

sarah
suyogkale2002
Registered: Apr 21 2009
Posts: 9
i want to reorder list_box items, like i will have MOVE UP ?DOWN buttons,
when i click on MOVE UP button selected item should swap with its earler item
when i click on MOVE DOWN button selected item should swap with its next item

let me know how to do it, is there any default sorting for list_box control if yes , how to disable it?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unfortunately Adobe did not do a full list box implementation when they added custom dialogs (the JSADM) to Acrobat. It's missing many common list box features. Items in a custom dialog list box are sorted lexically. I would have been better to do no sorting at all. That way we could at least arrange things the way we'd like. But, there are no other options.

However, you can make use of this default sorting by prefixing entries with numbers or letters. It looks a bit ugly but I do month lists this way (01:January, 02:Febuary, etc.) The colon ":" is necessary so that the item data can be parsed out.

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]

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