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.

Visible and Invisible

Avatar

Former Community Member

9 Replies

Avatar

Former Community Member
I have several textfields and checkboxes that I want to make "visible" and "invisible" via the status of another checkbox. I can do this using javascript: textfield.presence="visible".



Here is my question: Is there a way I can group all of the effected fields and boxes together to turn them on and off, or will I have to add each one of them separately to my "if else" statement? It works that way, but I have several fields that I want to turn on and off and was hoping for a way other than the brute force way I am currently doing it.



Thanks!



Stan

Avatar

Former Community Member
You could wrap them in a sub form and make the sub form "visible" and "invisible".

Avatar

Former Community Member
Thanks for the suggestion. I thought there might be a better way. Here is what I am trying. For a test, I opened a new form, placed two checkboxes on it. One of the checkboxes I wrapped into a subform. On "click" for the external checkbox, I have:



if (checkboxout.rawValue==true)

subform1.presence="visible";

else

subform1.presence="invisible";

endif



I also added:



subform1.presence="invisible";



to its initiate script so that the subform is invisible until the check box is checked. This is not working. The form is dynamic and when I preview, the subform is invisible, but checking the checkbox does not "turn on" the subform.



Ideas?

Avatar

Former Community Member
Mr. Moore,



I would try this code in the click event of the checkboxout:



if (checkboxout.rawValue == 1){

subform1.presence = "visible";

}

else {

subform1.presence = "invisible";

}



Now you can add the invisible presence statement in the initialize event or you can just set it to invisible on the Object tab/Subform tab.



I would look at using "hidden" in the initialize event as it will avoid having a blank spot that is being taken up by the invisible subform. However that requires a lot more thinking and setup of subforms so that everything flows correctly.



Rick Kuhlmann

Tech-Pro

Avatar

Former Community Member
Rick,



Thanks for the reply. I tried your suggestion and got the same results. Checking the checkbox has no effect on the visibility of the subform. The only script I have is in the click event of the checkbox. Ideas?



Thanks,



Stan

Avatar

Former Community Member
Stan,



Did you save the form? If you did, did you save it as a dynamic form?



Check under File/Form Properties/Defaults Tab and make sure the form is Interactive.



Lastly, make sure that the script you wrote is set to JavaScript and not FormCalc. Do that in the Script Editor.



Rick Kuhlmann

Tech-Pro

Avatar

Former Community Member
Rick,



I confirmed that all are correct.

Form is dynamic (I get the check rather than an X in the checkbox.)

Confirmed script is Javascript.

Confirmed that the form is interactive.



I know this should be straightforward, but I do not know what I am missing here.



Here is the script for the checkbox to turn the subform on and off:



----- form1.#subform[0].CheckBox2::click - (JavaScript, client)



if (checkBox2.rawValue == 1){

testsubform.presence = "visible";

}

else {

testsubform.presence = "invisible";

}



Here is the script in the subform initialize event, currently commented out.



----- form1.#subform[0].testsubform::initialize - (JavaScript, client) -----------------------------



//testsubform.presence="invisible";



These are the only scripts have have.



Stan

Avatar

Former Community Member
Hi Stan,



I was able to get it to work by changing the first line of your Javascript "Click" event of the checkbox2 from :



b if (checkBox2.rawValue == 1){



to



b if (this.rawValue == 1) {



and saving the file as "Acrobat 7 Dynamic".



Make it a great day!

Pam

Avatar

Former Community Member
Pam,



Thanks! That works for the subform. I can turn it "on" and "off" with the checkbox now. One more question: The fields, checkboxes, etc that I have assigned to the subform still do not show up. I did make sure they were in the front and visible. The subform displays (I put a border on it to confirm that the script was working), but nothing else.



Ideas?



Thanks,



Stan