Skip to main content
Participant
Jan 4, 2021 8:19 PM UTC
Question

Multi-option check boxes in a form

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!

 

15 replies

Thom Parker
Community Expert
Community Expert
Jan 6, 2021 1:10 AM UTC

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;
}

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
Nov 6, 2024 11:02 PM UTC

hi, can this be adjusted to have 4 states?

Translate
Thom Parker
Community Expert
Community Expert
Nov 7, 2024 2:21 AM UTC

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;
}

 

 

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
JR Boulay
Community Expert
Community Expert
Jan 5, 2021 2:41 PM UTC

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.

Translate
Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
Jan 5, 2021 11:11 AM UTC
Acrobate du PDF, InDesigner et Photoshopographe
Eric Dumas
Community Expert
Community Expert
Jan 5, 2021 11:27 AM UTC

Hi JR,

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

Translate
Bernd Alheit
Community Expert
Community Expert
Jan 5, 2021 3:02 PM UTC

Try a other browser.

Translate
try67
Community Expert
Community Expert
Jan 4, 2021 10:08 PM UTC

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".

Translate
Eric Dumas
Community Expert
Community Expert
Jan 5, 2021 11:25 AM UTC

I would consider a drop-down list

Translate