Skip to main content
Participant
October 9, 2024
Answered

Logical operations with checkbox fields

  • October 9, 2024
  • 1 reply
  • 457 views

I need to get a form with a list of checkboxes and a general checkbox that should be automatically checked if any of the checkboxes from the list is checked.

I think that the logical operator (check) will be the result of logical OR of the list checks (check1, check2, check3 and check4).

My javascript added to every list checkboxes doesn't work correctly:

 this.getField("check").value = ((this.getField("check1").value) || (this.getField("check2").value) || (this.getField("check3").value) || (this.getField("check4").value));

 

Could anyone help me to write this simple script?

This topic has been closed for replies.
Correct answer PDF Automation Station

Put the following custom calculation script into any text field:

var fld="check";
var fldValue="Off";
for(var i=1;i<5;i++)
{ 
if(this.getField(fld+i).value!="Off")
{fldValue=this.getField(fld+i).value}
}

if(fldValue!="Off")
{this.getField("check").checkThisBox(0,true)}
else
{this.getField("check").checkThisBox(0,false)}

1 reply

PDF Automation Station
Community Expert
Community Expert
October 9, 2024

Put the following custom calculation script into any text field:

var fld="check";
var fldValue="Off";
for(var i=1;i<5;i++)
{ 
if(this.getField(fld+i).value!="Off")
{fldValue=this.getField(fld+i).value}
}

if(fldValue!="Off")
{this.getField("check").checkThisBox(0,true)}
else
{this.getField("check").checkThisBox(0,false)}
Participant
October 9, 2024

Thank you!