Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

toggle button

Avatar

Level 4

How do I set up a button so the first time it is clicked it shows a hidden subform, but then when it is clicked again, it hides the subform?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Here is something similar. Instead of looping through images, it would change the presence.

It is based on having a global variable in the File / Form Properties / Variable tab called vCounter. It would look something like this in the click event:

switch (vCounter.value)

{

     case "1":

     subform1.presence = "visible";

     vCounter.value = "2";

     break;


     case "2":    

     subform1.presence = "hidden";

     vCounter.value = "1"; // changes counter back to 1

     break;

}

Hope that helps,

Niall

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

Hi,

Here is something similar. Instead of looping through images, it would change the presence.

It is based on having a global variable in the File / Form Properties / Variable tab called vCounter. It would look something like this in the click event:

switch (vCounter.value)

{

     case "1":

     subform1.presence = "visible";

     vCounter.value = "2";

     break;


     case "2":    

     subform1.presence = "hidden";

     vCounter.value = "1"; // changes counter back to 1

     break;

}

Hope that helps,

Niall

Avatar

Level 10

On the Click event for the button you can do the following (javascript):

switch (Subform1.presence) {
    case "hidden":
        Subform1.presence = "visible";
        break;
    case "visible":
        Subform1.presence = "hidden";
        break;
}

Avatar

Level 4

Thanks!

I also found this solution:

if (xfa.form.assessment.Interaction.presence == "visible") {


xfa.form.assessment.Interaction.presence = "hidden";
}
else {
xfa.form.assessment.Interaction.presence = "visible"
}

Avatar

Level 10

Jono's solution is much nicer, as it doesn't need the global variable at all!!

N.