Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Check both checkboxes to make text field visible

Explorer ,
Oct 27, 2023 Oct 27, 2023

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.

1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Oct 27, 2023 Oct 27, 2023

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;

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2023 Oct 27, 2023

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">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2023 Oct 27, 2023

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;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2023 Oct 28, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2023 Oct 28, 2023

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;

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2023 Oct 28, 2023

I'm sorry.  I didn't fully explain.  This would be for two different checkboxes to make a button visible if both checked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2023 Oct 28, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2023 Oct 28, 2023

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2023 Oct 28, 2023

You can put it in the same place where you put the first script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 28, 2023 Oct 28, 2023
LATEST

Thank you!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines