Skip to main content
Participating Frequently
November 10, 2016
Answered

Multichoice check boxes

  • November 10, 2016
  • 2 replies
  • 1165 views

I need to make a checkbox with three options. Checked, not checked, or a dash. I can sort of do this with a dropdown box, but was wondering if there was a way to do it with a checkbox.

This topic has been closed for replies.
Correct answer George_Johnson

Not with an actual check box, but you can fake it using a button. The following demo uses a button and text field combination. The button provides the UI and appearance, and the text field provides the means to get/set the value of what I call the composite field. It relies on JavaScript, so you'll have to study it to see how it works, and it won't work on most non-Adobe PDF viewers and most mobile PDF viewers.

Demo: http://www.acroscript.net/pdf/demos/multistate_4.pdf

Things can be simplified if you don't need to worry about getting/setting or importing/exporting the field value, but I don't have a demo for that.

2 replies

Participant
May 30, 2023

This is exactly what I need to do, but the PDF file listed in the answer is no longer available.

Can anyone help?

Thanks!

Nesa Nurani
Community Expert
Community Expert
May 30, 2023

What exactly are you trying to achieve?

Here is script for button that will change on each click: blank, green checkmark, red dashes:

if (event.target.buttonGetCaption()=="\u2714") {

event.target.buttonSetCaption("---");

event.target.textColor = color.red;

} else if (event.target.buttonGetCaption()=="---") {

event.target.buttonSetCaption("");

} else if (event.target.buttonGetCaption()=="") {

event.target.buttonSetCaption("\u2714");

event.target.textColor = color.green;

}

George_JohnsonCorrect answer
Inspiring
November 10, 2016

Not with an actual check box, but you can fake it using a button. The following demo uses a button and text field combination. The button provides the UI and appearance, and the text field provides the means to get/set the value of what I call the composite field. It relies on JavaScript, so you'll have to study it to see how it works, and it won't work on most non-Adobe PDF viewers and most mobile PDF viewers.

Demo: http://www.acroscript.net/pdf/demos/multistate_4.pdf

Things can be simplified if you don't need to worry about getting/setting or importing/exporting the field value, but I don't have a demo for that.

Scott_BIAuthor
Participating Frequently
November 10, 2016

The Multistate Checkbox is pretty much exactly what I need. I am nowhere an expert with Java though. Often I have found I can copy past just enough to get by. I copied both boxes and copied the script into "document Java Script" under "init" but the icons don't appear on my document. Also I need to change the X to a dash. Heavy Minus sign 2796 looks about right but I don't seem to be changing the entry correctly as it just stays an X.

Inspiring
November 10, 2016

If you're able to post your form somewhere and provide a link here, I'd be happy to take a look. If you can't, feel free to email me at: acroscript at gmail dot com