Skip to main content
Known Participant
December 14, 2017
Answered

Updating a ComboBox options list

  • December 14, 2017
  • 1 reply
  • 3631 views

I created a PDF with two ComboBoxes, call them A and B. I want the selection of A to alter the content of B. I have some other (hidden) ComboBoxes, whose names correspond to the values of A, and when the user selects a value in A, that ComboBox's options list should be copied to the B.

The Javascript I use (when a selection in A is made) is:

var Val = this.getField("A").value;

var c1 = this.getField(Val);

var B = this.getField("B");

B.clearItems();

for (var i=0; i < c1.numItems; i++) {

  B.insertItemAt ( c1.getItemAt(i, false), c1.getItemAt(i, true), -1 );

}

(I would have been simpler to use B.SetItems(c1.getItems)  or something like that, but I don't think there's a method like getItems, right?)

The lists are about 2000 items longs, and each time I select a value in A, Acrobat gets stuck for about a minute or more. Except that it works fine.

Is there any way to speed tup the process?

Thanks!

This topic has been closed for replies.
Correct answer Thom Parker

The data is saved in other ComboBoxes only for conveniece. The user doesn't really see them (they're hidden). Perhaps there's a different, more effective way to store the data?


Have you seen this article:

https://acrobatusers.com/tutorials/js_list_combo_livecycle

It uses a document level object to store list data.

1 reply

try67
Community Expert
Community Expert
December 14, 2017

Instead of inserting the items one by one I would save them into an array

and then use the setItems method to apply them all at once.

Known Participant
December 14, 2017

Thanks. There is a considerable improvement - it now takes only about 15 seconds.

But it's still a long time. Any way to further speed things up?

Known Participant
December 14, 2017

The data is saved in other ComboBoxes only for conveniece. The user doesn't really see them (they're hidden). Perhaps there's a different, more effective way to store the data?