Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

dropdown.addItem syntax issue

Avatar

Level 1

Can anybody suggest why the following function isn't working? addItem doesn't seem to accept "i" as an argument.

function

dropdownRange(dropdown,start,end,increment)

{

for (var i = start; i < end; i+=increment) {

     dropdown.addItem(i);

}

}

I'm am calling the function from a radio group change event that toggles the drop-down range:

functions.dropdownRange(mydropdown

,200,1500,100);

Thanks in advance

1 Accepted Solution

Avatar

Correct answer by
Level 10

Everything looks fine except the addItem syntax.

It must be written as:

dropdown.addItem(i+'');     // don't forget to convert the integer variable i to string here..

Thats all to go..

Nith

View solution in original post

4 Replies

Avatar

Level 1

A bit more information:

The code is returning the error:

"Argument mismatch in property or function argument"

I don't believe there is an argument mismatch though. If I add square brackets as if passing an array: dropdown.addItem([i]), the script runs successfully but with an 'empty' value for each item.

Avatar

Correct answer by
Level 10

Everything looks fine except the addItem syntax.

It must be written as:

dropdown.addItem(i+'');     // don't forget to convert the integer variable i to string here..

Thats all to go..

Nith

Avatar

Level 1

That's it! Thanks very much Nith.

It works but I don't understand why. Can you explain?

Avatar

Level 10

The addItem() methods accepts one or two string arguments.

The syntax is:

addItem(string param1[,string param2])

You were attempting to supply an INTEGER value as the parameter which caused that issue.

Nith