Skip to main content
Mythril1
Participant
March 22, 2018
Answered

Linked check boxes with a twist

  • March 22, 2018
  • 2 replies
  • 590 views

I have three check boxes: Toilet, Sink and Shower. Toilet needs to be able to be checked when neither of the others are. However, if either Sink or Shower (or both) are checked toilet must also automatically be checked. Is there some way to link these boxes to do this?

This topic has been closed for replies.
Correct answer try67

As the Mouse Up event of Sink and Shower enter this JavaScript code:

if (event.target.value!="Off") this.getField("Toilet").checkThisBox(0, true);

Be aware that this does not prevent the user from un-checking Toilet. If you want to do that then you would need to set it as read-only when one of the other two boxes are checked.

2 replies

Thom Parker
Community Expert
Community Expert
March 22, 2018

Another solution is to use a calculation script on a hidden text field. That way you capture all the checking and unchecking actions, and can set the checkbox values appropriately in all cases. Including setting the readOnly to prevent unwanted entries.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 22, 2018

As the Mouse Up event of Sink and Shower enter this JavaScript code:

if (event.target.value!="Off") this.getField("Toilet").checkThisBox(0, true);

Be aware that this does not prevent the user from un-checking Toilet. If you want to do that then you would need to set it as read-only when one of the other two boxes are checked.

Mythril1
Mythril1Author
Participant
March 22, 2018

Thank you. I'll try that.