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.

Use a check box to disable a page

Avatar

Former Community Member

Good morning,

I know what I want to do is very simple but I can't seem to figure it out. I have a form with multiple pages. On page 2, I have included a "not applicable" check box. If this check box is enabled, I would like all fields on page two to be disabled. All items (including the "not applicable" check box) on page 2 are wrapped in a subform called "page2". Thank you in advance fo ryour help.

Saskia

7 Replies

Avatar

Level 6

On the change event of "not applicable" check box write javascript to disable(means hopefully readonly i guess) of the "page2".

if(this.rawValue == '1'){

page2.access = "protected";

}

Hope this helps.

-Raghu.

Avatar

Former Community Member

Thank you. I tried this but I couldn't make it work. Do I need to define "protected" somewhere?

Avatar

Level 6

It should work, "p" is lowercase in "protected", just to make sure. If still have the issues e-mail the PDF to raghu.nagireddy@gmail.com if possible. Otherwise send a screen shot covered with script and field.

Avatar

Former Community Member

I demonstrated this functionality to the client and realized that once I enable the check box, that I cannot "unprotect" the page. So I guess I need an "else if" statement to go with this. What I'm worried about is that someone will select the "Not Applicable" check box and then change their mind. I looked for something that would be the opposite of "protect" but couldn't find anything. Any help is appreciated! 

Saskia

Avatar

Level 6

In the current situation even checkbox alro protected so may not uncheck. So divide "Page2" in to TWO separate subforms(lets say 'CheckBoxSubform' & 'Page2Subform').

Keep the "Not Applicable" check box in 'CheckBoxSubform' and rest of the fields/subforms on page2 keep in 'Page2Subform'.

1. If we check "Not Applicable" check box, then make the 'Page2Subform' as "protected".

2. If we uncheck "Not Applicable" check box, then make the 'Page2Subform' as "open".

Hope this helps.

Avatar

Former Community Member

As always, thank you for your help. I took a stab at the JavaScript but I'm sure I didn't do it right. The fields in Page2Subform are no longer protected when the check box is enabled. And when I initially click the check box, the "x" is grey but when I click it again, it is black. If I click a third time, it goes away. I kept the change event on the check box in CheckBoxSubform. Then I added the following:

 

form1.page2.CheckBoxSubform.notApp::change - (JavaScript, client)

if(this.rawValue == '1'){

page2.Page2Subform = "protected";

}

else if(this.rawValue == '0'){

page2.Page2Subform = "open";

}

Regards!

Avatar

Level 6

missed the ".access" in script.

form1.page2.CheckBoxSubform.notApp::change - (JavaScript, client)

if(this.rawValue == '1'){

page2.Page2Subform.access = "protected";

}

else if(this.rawValue == '0'){

page2.Page2Subform.access = "open";

}

Hope this will work, if still any issues email the form if possible.