Check box edit with Javascript ," coler Uncheck ect.. "

I looking for a list of commands to change the value of a check box.

Set/change boarder color
Set/change color of the check box style or font what ever that falls under
Turn Read only on or off

Check or uncheck the box " this.getField("Check Box5").value == "" On, Yes, True" did not work




Jason zastrow


4 Answers

Voted Best Answer

If you don't know the export value of a specific check-box (or don't want to hard-code it into your script), you can also use the checkThisBox method, which takes two parameters, the widget number and a boolean for the new value. So you can use it like this to tick a box on, for example:

this.getField("CheckBox1").checkThisBox(0, true);

.


Visit my custom-made PDF scripts website: http://try67.blogspot.com
Contact me personally: try6767@gmail.com


By Gilad D (try67)   

All these elements you want to change are part of the "normal" field properties. which are documented in the Acrobat SDK - specifically in the "JavaScript for Acrobat API Reference". Take a look at the field properties:

http://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/index.html#t=Acro12_MasterBook%2FJS_API_AcroJS%2FField_properties.htm

The border color is changed via the strokeColor poperty, the text color via textColor, read only via readonly and so on.

A checkbox has two values: "Off" for the unchecked state, and "Yes" is the default for the checked state, but you can change that via the field properties. Your snippet does not check/uncheck the box, it is using the comparison operator ('=='), so it was comparing it's current state with whatever you used.

To check a checkbox that was not modified (has it's original default export value), you can use this:

this.getField("CheckBox").value = "Yes";

To uncheck the box, use this:

this.getField("CheckBox").value = "Off";

Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com


Karl Heinz Kremer   

Question?

this.getField("Check Box 1").checkThisBox(0, true);

What is the 0 for in (0, true);

Also can't seem to get the Readonly or color change to work

if
(this.getField("Check Box5").value == "Yes" && this.getField("Check Box2").value == "Yes" && this.getField("Check Box10").value == "Yes") {
this.getField("Check Boxa").checkThisBox(0, true);
this.getField("Check Boxa").strokeColor = color.black;
this.getField("Check Boxa").readonly = false;
}
else {
this.getField("Check Boxa").checkThisBox(0, false);
this.getField("Check Boxa").strokeColor = color.gray;
this.getField("Check Boxa").readonly = true;
}


Jason zastrow   

Somedays i hate Javascript got it to work

if
(this.getField("Check Box5").value == "Yes" && this.getField("Check Box2").value == "Yes" && this.getField("Check Box10").value == "Yes") {
this.getField("Boxa").strokeColor = ["RGB",0,0,0];
}
else {
this.getField("Boxa").strokeColor = color.gray;
}

don't know why but if i do strokeColor = color."a color"; it will stay gray
and if i set the gry one to the RBG code it turns off the color


Jason zastrow   


Please specify a reason: