Skip to main content
Inspiring
December 30, 2019
Answered

Tristate Button

  • December 30, 2019
  • 1 reply
  • 3606 views

Hello,

 

I am creating a workbook with Adobe Acrobat DC Forms function.  I have one question with a set of six selections for which I want the particpants to mark each selection with a check (green if possible) or an "x" (red if possible).  I have spent quite a while searching for the answer on how to insert a "tristate" checkbox or radio button, but all the links in these forums where someone has solved the issue seem to be broken or are not operating properly.

 

Any help would be appreciated; however, I have no experience coding in Adobe.  So, if your answer includes coding, could you point me in the direction of how to actually access that part of the code?  I have tried to open a few things, but it would appear that coding was easier in previous versions (or maybe I'm just not seeing something properly).

 

Thank You,

 

--Steven

This topic has been closed for replies.
Correct answer sjhace

Excellent! Use whatever font works. The important bit is that it is embedded in the PDF. Actually it's the Symbol font I was thinking about, not Wingdings.  The Symbol font is type1. Its always available to PDF viewers so it doesn't need to be embedded. The checkbox uses ZapfDingbats.  AdobePI provides the same symbols as ZapfDingbats.  The check is characer "4" and the X is character "5".  No need to use the unicode. So I'll be using Adobe Pi for the script. You'll need to substitute the character values for your font.

 

if(color.equal(event.target.textColor,color.black))
{
     event.target.textColor = color.green;
     event.target.buttonSetCaption("4");
}
else if(color.equal(event.target.textColor,color.green))
{
     event.target.textColor = color.red;
     event.target.buttonSetCaption("5");
}
else
{
     event.target.textColor = color.black;
     event.target.buttonSetCaption("");
}

 

So, this code creates a single 3-state button. It's gets even more complicated if you want to use the 3-state value for something, or to use it as a radio button. 

 

 


Dear Thom,

 

Worked like a champ.  Thank you so much for the help!

 

I am an author, and I am working on a workbook for my print book.  It is religious in nature, so no pressure.  But, if you'd like a free copy of the ebook (epub), please visit this site: https://www.smashwords.com/books/view/753401

 

I've placed it free here ending today.

 

Thank You,

 

--Steven

1 reply

Thom Parker
Community Expert
Community Expert
December 30, 2019

So, you would like a checkbox that clicks through 3 states, red X, green check, and blank. Is this correct?

 

This functionality is not built into Acrobat, but can be accomplished with scripting. Be warned that such a solution will only operate on a viewer that supports the JavaScript necessary for the implementation, which means it won't work on mobile viewers, web browser viewers, and many of the cheap 3rd party PDF viewers. 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
sjhaceAuthor
Inspiring
December 30, 2019

Hello Thom,

 

Yes, that is correct (the 3 states you mention).

 

As for viewers, it is my intention that people will mostly access this on an iPad.  Would that be considered a mobile viewer?  If so, what would it do instead (an error, shut down, etc.)?

 

Thank You,

 

--Steven

Thom Parker
Community Expert
Community Expert
December 30, 2019

I don't think that the Adobe Reader for iPad would work, but maybe. The best bet for this type of thing is PDF Expert from Readdle. 

 

On other viewers the behavior would depen on the implementation. But it wouldn't cause a crash. The script just wouldn't do anything. 

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