Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Visible and Invisible

Avatar

Not applicable

9 Replies

Avatar

Not applicable
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

Not applicable
You could wrap them in a sub form and make the sub form "visible" and "invisible".

Avatar

Not applicable
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

Not applicable
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

Not applicable
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

Not applicable
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

Not applicable
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

Not applicable
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

Not applicable
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