Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments

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

Level 6
I think it is the [0] in this line:



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

Avatar

Not applicable
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.