Skip to main content
Known Participant
October 4, 2023
Answered

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

  • October 4, 2023
  • 3 replies
  • 1916 views

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

This topic has been closed for replies.
Correct answer bebarth

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).

@+

3 replies

bebarth
Community Expert
bebarthCommunity ExpertCorrect answer
Community Expert
October 4, 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).

@+

Known Participant
October 5, 2023

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

Bernd Alheit
Community Expert
Community Expert
October 4, 2023

Where does you use the script? 

Known Participant
October 4, 2023

In Javascript area from checkbox 1 and 2 

try67
Community Expert
Community Expert
October 4, 2023

Where did you put this code?

Known Participant
October 4, 2023

Javascipt, mouse up on Checkbox 1 and 2

try67
Community Expert
Community Expert
October 4, 2023

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