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.
SOLVED

Have multiple scripts for one custom button

Avatar

Level 9

Can I run different scripts when clicking the same custom button based on the selection in a drop-down object? The selection in the dropdown determines which script runs.

For example: if the dropdown selection is "A"  - sustom button runs script A

If the selectionin the dropdown is "B" - the same custom button only runs script B.

Note: Each script contains a few if statements

How do I script that?

1 Accepted Solution

Avatar

Correct answer by
Level 10

You need to use an if...else statement.

if (dropdown == "A") {

     do stuff;

}

else if (dropdown == "B") {

     do other stuff;

}

else if (etc.) {

     do more stuff;

}

And you can nest if statements inside of other if statements.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

You need to use an if...else statement.

if (dropdown == "A") {

     do stuff;

}

else if (dropdown == "B") {

     do other stuff;

}

else if (etc.) {

     do more stuff;

}

And you can nest if statements inside of other if statements.

Avatar

Level 9

Thanks Jono. That will make this much easier!