Expand my Community achievements bar.

Hide/Show Collection of controls

Avatar

Former Community Member
I would like to have a button that when clicked will show a group of text and textboxes. Is this possible? How can I go about doing this.
5 Replies

Avatar

Former Community Member
You need to define your fields in a subform within designer and give the subform some name to identify it. There is a presence attribute which sets the visibility of an object within the form. However this is only partially effective when you are trying to hide multiple objects. Currently setting Subform.presence = "invisible" will only hide text fields within the subform. It does not hide anything else or indeed hide nested subforms. <br /><br />What you need to do is to recurse into the subform and set each objects presence attribute (to be sure). The following example shows how this can be accomplished from the click event of a button. You could add the function to a script object<br /><br />if (MySubform.presence == "visible")<br />{<br /> displaySubformContents(MySubform, false);<br />} else {<br /> displaySubformContents(MySubform, true);<br />}<br /><br />function displaySubformContents(oSubform, bDisplay)<br />{<br /> var presenceSetting = (bDisplay ? "visible" : "invisible");<br /> for (var i=0; i<oSubform.nodes.length; i++)<br /> {<br /> var oObject = oSubform.nodes.item(i);<br /> if (oObject.className == "draw" || oObject.className == "field")<br /> {<br /> oObject.presence = presenceSetting;<br /> } else {<br /> if (oObject.className == "subform" || oObject.className == "exclGroup")<br /> {<br /> displaySubformContents(oObject, bDisplay);<br /> }<br /> }<br /> oSubform.presence = presenceSetting;<br />}

Avatar

Former Community Member
I've entered the code on the button's click even and it does not seem to be working. I have a subform with one text box in it. The subform is titled "MySubform" and the textbox has the default name.

Avatar

Former Community Member
Set the scripting to javascript, run at client and make sure your document is saved as a dynamic PDF in Designer 7. You cannot to this in Acrobat 6 compatible static PDF's

Avatar

Former Community Member
Aha! That did it. Weird so I won't be able to click the PDF Preview tab in Designer to make sure things are working ok? At any rate thanks again for the great help!

Avatar

Former Community Member
Once you have the Dynamic PDF set, documents generated in the PDF preview should also be dynamic.