Skip to main content
boilermaker73
Inspiring
November 28, 2022
Question

Working with arrays to populate a combo box and associated text fields

  • November 28, 2022
  • 2 replies
  • 2654 views

I have a multi-dimensional array of the form [[a1,a2,a3,a4,a5],[b1,b2,b3,b4,b5],[c1,c2,c3,c4,c5].....] whereby I have written a script to populate a combo box using data extracted from the first element of each multidimensional array provided in which case the combo box contains only the first element in each array or a1,b1,c1,.... The trick is depending on the value selected in the combo box, I would like to automatically assign the remaining elements in the array associated with combo box selection to appear in the remaing fields on the form. In other words if I were to select a1, the remaining items a2, a3, a4, a5, would display in the remaining fields on the form. Likewise, if I were to select b1, the remaning items b2,b3,b4,b5 would be displayed. Unfortunately. no matter what scripts I have tried thus far using for loops along with the getItemAt, numItems methods, including the multidimensional array I created in a for loop in an attwmpt to achieve the same result, I have been unable to display the remaining associated elements of the array on my form regardless of the value selected in the combo box. Any thoughts, suggestions, tutorials regarding this subject matter are most appreciated.  Last but not least, I should probably add that for whatever reason it appears I am having a difficult time obtaining the true index number associated with the combo box selection since I can easily enough assign any value from the array using an element's appropriate index numbers such as [0]02] to assign a3. Thank you ahead of time. 

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
November 28, 2022

Where is this "array" defined? What is it's name? Is it in a document level script?  

Where is the script that sets up the first combobox?  And how does it work?  Can you post it?

 

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
boilermaker73
Inspiring
November 29, 2022

Attached hereto find an abbreviated dummy prototype form dependent on a multidimensional array with data intended to populate/display in several form fields associated with the selection made in the combo box for which I have provided several form fields. For example, if the user were to select 'Adobe' from the combo box field, I would like the remaining fields, i.e., date entered, website, user ID/Email, and password, to automatically display the data in the array associated with Adobe.  As previously mentioned, I have been unable to date to create|add a script to the 'mouse up' event of the combo box to populate and display the remaining data from the array associated with the value selected in combo box. Any comments, suggestions regarding this subject matter are most appreciated. Thank you ahead of time.  

boilermaker73
Inspiring
November 29, 2022

Once again I should emphasize that my issue appears to be related to my not being able to obtain the current index of the selected value in the combo box in order to be able to assign|display the correct values, i.e., the remaining data in the multidimensional array associated with the name selected in the combo box, for the other fields on the form.  

try67
Community Expert
Community Expert
November 28, 2022

So you have a drop-down (combo-box) field with all the first items from the low-level arrays, and when one of them is selected you want to populate the values from the rest of the array to some other fields, basically?

 

boilermaker73
Inspiring
November 29, 2022

Correct. I have since attached a prototype PDF form containing the array, combo box, and several form fields providing an abbreviated version of the form yet to be completed.