Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

prepopulate dropdown using script object

Avatar

Level 2
i have no java errors at all, my items have been prepopulated with only the first letter

in my dropdown i get

A

A

A

A

B

B

B and so on



this is my script object



form1.purchaseOrder.#variables[0].carparts - (JavaScript, client)



var carpart = new Array(new Array(243));



carpart[0] = " ";

carpart[1] = "AC Assembly Complete";

carpart[2] = "AC Compressor";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

carpart[240] = "Windshield Washer Motor";

carpart[241] = "Wiper Motor Front";

carpart[242] = "Wiper Motor Rear";



// This function will populate the carpart Drop-down List.

// This function is called from the initialize event of the carpart Drop-down List.



function getcarpart(dropdownField)

{

dropdownField.clearItems();

for (var i=0; i < carpart.length; i++)

dropdownField.addItem(carpart[i][0]);

}



---------------------------------

in my dropdown i have this



form1.purchaseOrder.details.detail.carpart1::initialize - (JavaScript, client)



carparts.getcarpart(this);



---------------



if there is an easier way to prepolulate several identical dropdowns with the samne data i am willing to change my method



can anyone help
3 Replies

Avatar

Former Community Member
I think it is the [0] in this line:



for (var i=0; i < carpart.length; i++) dropdownField.addItem(carpart[i][0]); }

Avatar

Former Community Member
As Bishop stated. You for loop for carpart is breaking the work into a character array, so you are attempting to reference the first character of the "i" array item.