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

Checkboxes affect other checkboxes

Participant ,
Mar 12, 2020 Mar 12, 2020

I want option of one checkbox to affect multiple other checkboxes. When user clicks on a "Service" checkbox, program needs to then check one or more "Task" checkboxes later in the document.  But I want the Task checkboxes to be read only, so I can't name them the same.  Secondly,  multiple Service checkboxes to affect one Task checkbox.  

Scenario: 

   Service1,  Service2, Service3 OR Service4 , Service5

   Task1, Task2, Task3, Task4, Task5  (read only checkboxes, have same export value as their single related Service checkbox)

   Currently using script for each Service to turn on a single Task checkbox.(Service1-Task1, Service2-Task2, etc).  and have two identical Task boxes (3 & 4) so I can link to Service 3 or 4).

if(event.target.isBoxChecked(0))

{// Perform actions when checked

   this.getField("Task1").checkThisBox(0,true);

}

else

{// Perform actions when unchecked

   this.getField("Task1").checkThisBox(0,false)

}

Issue#1:  User has choice of Service3 orService4, but both utilize same Task3.  But they won't both work with checking Task 3.  I could change both Service3,4 to Service3 with different export values, but how do I combine script to say if either is checked, to check Task 3, otherwise uncheck.

 

Issue #2:  Service1 and Service2 could each affect Task 1 and Services1,2&3 affect Tasks4 and 5.  How do I get them both to work without cancelling the other one's actions?

 

I hope this makes sense!  TIA ~ Michelle

594
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 ,
Mar 12, 2020 Mar 12, 2020
LATEST

Since you have a somewhat complex scenario, I'd suggest using a calculation script in a hidden field to manage the automatic checking. A calculation script is run any time any field on the form is changed. So this script will catch all checkbox changes. The script can then get all the service values and evaluate them all at the same time.

 

Something like this

 

var s1 = this.getField("Service1").isBoxedChecked(0);

var s2 = this.getField("Service2").isBoxedChecked(0);

...etc...

if( ... combination of service checks)

{

  .. Set task checks ...

}

else if( ... combination of service checks)

{

  .. Set task checks ...

}

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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