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

Can't get code to work to multiple check boxes. Forms Javascript.

Explorer ,
Oct 04, 2023 Oct 04, 2023

I want to be able to  check checkbox 1, then checkbox 2. If both of those boxes are checked I want checkbox 4 to be automatically checked. This is what I have tried but it does not work. Any help would be great. Thanks. 

var checkbox1 = this.getField("Checkbox1").value;
var checkbox2 = this.getField("Checkbox2").value;

if (checkbox1 === "Yes" && checkbox2 === "Yes") {
this.getField("Checkbox4").value = "Yes";
} else {
this.getField("Checkbox4").value = "Off";
}

TOPICS
PDF forms
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 04, 2023 Oct 04, 2023

Hi,

There must be an error, maybe in the export value of a checkbox ("Yes" spelled wrong???) because the script is correct.

And here you can use either the strict equality symbol (Checkbox1) or the simple equality symbol (Checkbox2).

@+

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 04, 2023 Oct 04, 2023

Where did you put this code?

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 04, 2023 Oct 04, 2023

Javascipt, mouse up on Checkbox 1 and 2

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 04, 2023 Oct 04, 2023

Move it to be the Calculation script of a (hidden) text field.

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 04, 2023 Oct 04, 2023

Where does you use the 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 04, 2023 Oct 04, 2023

In Javascript area from checkbox 1 and 2 

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 04, 2023 Oct 04, 2023

Hi,

There must be an error, maybe in the export value of a checkbox ("Yes" spelled wrong???) because the script is correct.

And here you can use either the strict equality symbol (Checkbox1) or the simple equality symbol (Checkbox2).

@+

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 05, 2023 Oct 05, 2023

Thank you, will check again. Had some odd things with Acrobat forms lately.

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 05, 2023 Oct 05, 2023
LATEST

Thanks again, I know where I made my "rookie" mistake.

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