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

Populate Combobox's with numbers

Gheezer
Registered: Feb 16 2009
Posts: 19
Answered

I have 5 comboboxes and I would like to populate each of them when the form is open with numbers 0 to 100 at increments of 5 (0, 5, 10 ,15, etc...) This is what I have.

function POPULATE_WEIGHTING()
{
// CREATING ARRAY OF WEIGHTING FIELDS
var WEIGHTING_ARRAY = new Array(
this.getField("Weighting.1"),
this.getField("Weighting.2"),
this.getField("Weighting.3"),
this.getField("Weighting.4"),
this.getField("Weighting.5"));

// POPULATE WEIGHTING FIELDS
for (i = 0; i < WEIGHTING_ARRAY.length; i++)
{
for (a = 0; a < 21; a++)
{WEIGHTING_ARRAY[i] = new Option(a * 5 + "%",a * 5)};
};
}

I know that POPULATE WEIGHTING FIELDS is not correct. What is the correct method?

Thanks.

My Product Information:
Acrobat Pro 8.1.1, Windows
efos
Registered: Jan 8 2009
Posts: 63
WEIGHTING_ARRAY[i].insertItemAt(a * 5 + "%",a * 5,-1)

-1 adds it at the end of the list, 0 (default) adds it to the top.

The FAQ thread in this forum has a link to the Javascript for Acrobat API Reference: get it, use it. Normally I would say "love it" but it feels a bit spotty in places.
Gheezer
Registered: Feb 16 2009
Posts: 19
efos wrote:
WEIGHTING_ARRAY[i].insertItemAt(a * 5 + "%",a * 5,-1)

-1 adds it at the end of the list, 0 (default) adds it to the top.

The FAQ thread in this forum has a link to the Javascript for Acrobat API Reference: get it, use it. Normally I would say "love it" but it feels a bit spotty in places.
Thanks for the help and the reference. I was wondering where a guide was located.

The following script works but the default value does not get set properly. Instead of "-" it defaults to "100%"

(function POPULATE_WEIGHTING()
{
// CREATING ARRAY OF WEIGHTING FIELDS
var WEIGHTING_ARRAY = new Array(
this.getField("Weighting.1"),
this.getField("Weighting.2"),
this.getField("Weighting.3"),
this.getField("Weighting.4"),
this.getField("Weighting.5"));

// POPULATE WEIGHTING FIELDS
for (i = 0; i < WEIGHTING_ARRAY.length; i++)
{
WEIGHTING_ARRAY[i].insertItemAt("-","-",0);

for (a = 0; a < 21; a++)
{
WEIGHTING_ARRAY[i].insertItemAt(a * 5 + "%",a * 5,-1)
WEIGHTING_ARRAY[i].DefaultValue = "-";
WEIGHTING_ARRAY[i].setAction("OnBlur", "TALLY_FIELDS();");
};
};
}
)

();