Copy link to clipboard
Copied
I have two checkboxes - Checkbox1 and Checkbox2. I also have a text field - TextField1. I would like TextField1 to become visible only if both Checkbox1 and Checkbox2 are checked. If either of the two checkboxes is unchecked, I would like TextField1 to remain hidden. Thanks for any assistance with either javascript or a calculation script.
Copy link to clipboard
Copied
Use this as 'Custom calculation script' of text field:
var c1 = this.getField("Checkbox1").valueAsString;
var c2 = this.getField("Checkbox2").valueAsString;
event.target.display = (c1 !== "Off" && c2 !== "Off") ? 0 : 1;
Copy link to clipboard
Copied
assuming acrobat
in the future, to find the best place to post your message, use the list here, https://community.adobe.com/
p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.
<"moved from using the community">
Copy link to clipboard
Copied
Use this as 'Custom calculation script' of text field:
var c1 = this.getField("Checkbox1").valueAsString;
var c2 = this.getField("Checkbox2").valueAsString;
event.target.display = (c1 !== "Off" && c2 !== "Off") ? 0 : 1;
Copy link to clipboard
Copied
Thank you. Works perfectly. I am also trying to do the same thing with a button (both checkboxes need to be checked in order to make the button visible). Your code works for text fields, but not for buttons. Could you also help with that. Thanks.
Copy link to clipboard
Copied
If it's the same checkboxes you can add this part to the script, just change "Button1" to your actual button field name:
this.getField("Button1").display = (c1 !== "Off" && c2 !== "Off") ? 0 : 1;
Copy link to clipboard
Copied
I'm sorry. I didn't fully explain. This would be for two different checkboxes to make a button visible if both checked.
Copy link to clipboard
Copied
In that case, copy first script and paste it under that script, replace last line with the line I gave you, rename two checkboxes and variables.
Copy link to clipboard
Copied
Would the code go into the Run a JavaScript in the button Actions tab, as the button does not have a Custom Calculation Script box like a text field does.
This is what I entered in the Run a JavaScript in the button, which does not seem to work (all fields are renamed to match the box names):
var c1 = this.getField("Vacant land OTP checkbox").valueAsString;
var c2 = this.getField("Property condition report completed no checkbox").valueAsString;
this.getField("Print Vacant Land Disclosure Report button").display = (c1 !== "Off" && c2 !== "Off") ? 0 : 1;
Copy link to clipboard
Copied
You can put it in the same place where you put the first script.
Copy link to clipboard
Copied
Thank you!