Skip to main content
Participant
February 4, 2024
Question

Any way to create a tiered check-box?

  • February 4, 2024
  • 4 replies
  • 2288 views

I am creating a PDF form, and I would ideally like to have a checkbox that has three states: unchecked, checked, or double-checked. I then want to use the state of the checkbox to drive the value of another field. I know how to do the last part, but not the first. I could use two checkboxes or even a drop-down, but neither of those fits what I have in mind. Ideally, the user would click the box once to check it, again to double-check it (which would have a distinct appearance), and a third time to uncheck it again.

Any suggestions or alternative ideas would be appreciated!

This topic has been closed for replies.

4 replies

JR Boulay
Community Expert
Community Expert
February 5, 2024

See attachment, you can edit the script to change the characters and the colors.

This is a much simpler example.

 

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Community Expert
February 4, 2024

Take a look at the toggle button samples at the bottom of this page.

https://www.pdfscripting.com/public/Free-Sample-PDF-Files-with-scripts.cfm

 

Creating a state buttons require maintaining a state value.  To implement a 3-state button the state value has to be stored in a persistent location that can handle 3 separate values, for example a hidden text field. In addition you'll need to store 3 images, one for each state. A single hidden button will work for this.

 

So, to implement a 3 state button you'll need

* One visible button (this UI for the button)

* One hidden text field (for storing the state data)

*One hidden button field (for storing the 3 state images)

 

Additional 3-state buttons can use the same hidden fields. However, you'll need to use a more advanced data storage technique with the hidden text field for storing state data for multiple buttons.  

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
February 4, 2024

Now that I'm looking at it. You can use the visible button caption to store the state data, even though the button is set to Icon Only, so the caption will never be shown.   The hidden text field is not needed, but you'll still need the hidden button to store the state icons. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
February 4, 2024

Thanks Thom! I stumbled upon this other thread of you helping someone with something similar
https://community.adobe.com/t5/acrobat-discussions/tristate-button/td-p/10826731
I managed to get the visual behavior I wanted using a custom button like that, but can't seem to find a way to use the button state as a variable input to other calculations using this.getField("ButtonName").value

Am I missing something, or do buttons not have output values, or is this what you mean by having a hidden text field (for storing the state data)?

try67
Community Expert
Community Expert
February 4, 2024

You can use a button to do it. Try searching the forum for "tri-state fields".

ls_rbls
Community Expert
Community Expert
February 4, 2024

Hi @Nick311037523ol3 ,

 

Acrobat checkbox widgets don't have a double-check status, but the desired action that you're inquiring about may be accomplished may be by adding a conditional statement in your script.