One of the common tasks is to enable / disable or show / hide a form object based on the value in a related checkbox, or even a value in a drop down box. Unfortunately, there are not that many resources that walk you through this particular task, so the following article will discuss the steps involved, and highlight the Livecycle actions object.
First, start with a blank PDF like the one below and then drag a checkbox onto the page followed by the text box that you would like to connect to the checkbox. This could be any type of control, and in fact you will need to add a plain text item to the form in many cases so you have an area that will allow you to explain the action that you are performing. The image below shows the object library and highlights the objects that will be used.
Next, make sure the object explorer is open, to do this just click on view, and then object editor as in the image below.
The object explorer will appear with a heading of Object and a set of tabs named field, value, and binding. Clicking on the binding tab will display the object name. For this example change the object name to cb for your checkbox and tb for your textfield.
You change the control by clicking on the object in the design view panel.
After renaming the textbox to tb go ahead and click on the ‘Field’ tab of the textbox object and make this invisible by changing the value in the ‘Presence’ section to invisible.
Now that they are named something fairly easy to remember let’s add some interaction to the checkbox. To do this we need to look at the built in actions that adobe provides by right clicking on the object, which in this case is the check box. The image above shows the checkbox after we have left clicked on it (it should be highlighted in purple). The right click menu is shown below, select actions from the list then click on the add action button.
I have attached a screen shot of the box that pops up when you press this button below.
When dealing with a checkbox you have three choices in the top dropdown, is checked, is clicked, or is unchecked. In the bottom dropdown box you have a long list of prebuilt actions that you can apply to the condition in the top dropdown. To show or hide our textbox select Show or Hide Object from the list in the result box of the action builder. You will then see what looks like a hyperlink which allows you to select the object you want to hide or show and a dropdown to toggle between visible, hidden, or invisible.
Now remember when you select is checked and then change the object tb to visible in this example you have to also add an action that changes the object to invisible when the checkbox is unchecked. To do this select the new action button on the top of the add/edit action window. I have highlighted it in yellow in the image below
Finally, for the Pièce de résistance, all of this works great but what if a user saves the form with the checkbox checked and we have set our initial ‘Presence’ value for the textbox to invisible? That’s right the box will be checked and the textbox will not show since our action takes place on a click or change to the textbox. To correct this we need to now go further into the pdf and add some custom code that runs on form initialize.
In this case we have to now open the script editor and put some code in the form initialize event. The script editor window can be found under the window option on the top toolbar.
This window works just like any of the other windows in the application as the code changes depending on what object you have clicked in Livecycle. Before we get to the events let’s change to the correct object which is the form. In the hierarchy pane on the top left hand corner of Livecycle go ahead and click on the form.
Once you open the window you have to change a few settings to get to the right place in the document and also set the correct language. The image below shows the options that must be selected which I highlighted in yellow.
Now for the code:
Here’s a cut and paste version.
if (this.resolveNode("cb").rawValue == "0") {
this.resolveNode("tb").presence = "invisible";
}
if (this.resolveNode("cb").rawValue == "1") {
this.resolveNode("tb").presence = "visible";
}
Here’s what it looks like in Livecycle.
















