Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

DropDown List Item Values

Avatar

Level 2

I am using the following script to populate a drop-down list:

var myDdl = new Array(" ",

"Item1 ",

"Item2 ",

"Item3 ");

function populateMyDdl(dropdownField)

{

var i;

for (i=0; i < myDdl .length; i++)

dropdownField.addItem(myDdl [i]);

)

The drop-down list is populated just fine, but now I would like to add values to the items.  What's the proper syntax to give " " a rawValue of 0, Item1 a rawValue of 1, etc...?

Any help is greatly appreciated.

Thanks,

J

1 Accepted Solution

Avatar

Correct answer by
Level 6

update the addItem code to take both display item and bound items values.

dropdownField.addItem(myDdl [i], i);

sysntax of addItem:

addItem( STRING param1 [, STRING param2 ] )

param1 - Display Item value

param2 - Bound Item Value

View solution in original post

1 Reply

Avatar

Correct answer by
Level 6

update the addItem code to take both display item and bound items values.

dropdownField.addItem(myDdl [i], i);

sysntax of addItem:

addItem( STRING param1 [, STRING param2 ] )

param1 - Display Item value

param2 - Bound Item Value