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

Check both checkboxes to make text field visible

New Here ,
Oct 27, 2023 Oct 27, 2023

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.

Views

366

Translate

Translate

Report

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

correct answers 1 Correct answer

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;

Votes

Translate

Translate
Community Expert ,
Oct 27, 2023 Oct 27, 2023

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">

Votes

Translate

Translate

Report

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

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;

Votes

Translate

Translate

Report

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
New Here ,
Oct 28, 2023 Oct 28, 2023

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.

Votes

Translate

Translate

Report

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

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;

 

Votes

Translate

Translate

Report

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
New Here ,
Oct 28, 2023 Oct 28, 2023

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.

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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
New Here ,
Oct 28, 2023 Oct 28, 2023

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;

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
New Here ,
Oct 28, 2023 Oct 28, 2023

Copy link to clipboard

Copied

LATEST

Thank you!

Votes

Translate

Translate

Report

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