Skip to main content
Participant
January 4, 2021
Question

Multi-option check boxes in a form

  • January 4, 2021
  • 4 replies
  • 2697 views

Hello!

 

How would I create a checkbox that: 

If clicked once, shows "checked"

If clicked twice, shows "strike through"

If clicked three times, shows blank

 

Please send over any tips, thanks!

 

4 replies

Thom Parker
Community Expert
Community Expert
January 6, 2021

Here's a simple script for creating a 3-state button. Put it in the "MouseUp" action on the button. The font for the button needs to be set to a plain type 1 font, like Helvetica. The the button option to Label Only. 

You could also change the border and background properties with each click.

 

var strDash = "\u2014";
var strCheck = "\u2713";
var strVal = event.target.buttonGetCaption();
switch(strVal)
{
	case "":
	   event.target.buttonSetCaption(strCheck);
	   break;
	case strCheck:
	   event.target.buttonSetCaption(strDash);
	   break;
	case strDash:
	default:
	   event.target.buttonSetCaption("");
	   break;
}

 

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

hi, can this be adjusted to have 4 states?

Thom Parker
Community Expert
Community Expert
November 7, 2024

Absolutely, just add another case statement. 

 

var strDash = "\u2014";
var str4thState = "4";
var strVal = event.target.buttonGetCaption();
switch(strVal)
{
	case "":
	   event.target.buttonSetCaption(strCheck);
	   break;
	case strCheck:
	   event.target.buttonSetCaption(strDash);
	   break;
	case strDash:
	   event.target.buttonSetCaption(str4thState);
	   break;
	case str4thState:
	default:
	   event.target.buttonSetCaption("");
	   break;
}

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
JR Boulay
Community Expert
Community Expert
January 5, 2021

Using the browser you will only see a blank page with a white button with a green check, you must find the "Download" button and open it with Acrobat Pro.

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
January 5, 2021
Acrobate du PDF, InDesigner et Photoshopographe
Eric Dumas
Community Expert
Community Expert
January 5, 2021

Hi JR,

I clicked on your link and it opened Document Cloud in the browser, but no document was visible.

Bernd Alheit
Community Expert
Community Expert
January 5, 2021

Try a other browser.

try67
Community Expert
Community Expert
January 4, 2021

A check-box can't do that. You can use a button field to do it, though, using a script. Try searching the forum for "tri-state field".

Eric Dumas
Community Expert
Community Expert
January 5, 2021

I would consider a drop-down list