Skip to main content
Known Participant
July 3, 2025
Answered

Change border if checkbox is checked

  • July 3, 2025
  • 1 reply
  • 560 views

I have a button called Button1 and a checkbox called Checkbox1.  Button1 currently has a red thin border.  If Checkbox1 is checked, I would like the border to change to green medium.  Is this possible?

Correct answer PDF Automation Station

One more thing.  Is it possible to change the border color and the fill color if a button if text is entered in a text field.  Example, if text is entered in Text Field1, can the border color and the fill color of Button1 be changed from red to green?


Enter the following custom calculation script in the text field:

if(event.value)

{

//Your script if the text field contains a value

}

else

{

//Your script if the text field does not contain a value

}

1 reply

PDF Automation Station
Community Expert
Community Expert
July 3, 2025

Enter the following Mouse Up action script in the check box:

var oFld=this.getField("Button1");
if(event.target.value=="Off")
{
oFld.borderColor=color.red;
oFld.lineWidth=1;
}
else
{
oFld.borderColor=color.green;
oFld.lineWidth=2;
}
Known Participant
July 3, 2025

That worked.  Thank you!

Is there a way to also change the fill color of Button1 when Checkbox1 is checked?  From its current shade of light red to a light green?  I tried adding this to your script:  oFld.fillColor=["RGB", 191 , 255, 191]

but that does not work.  I changes the color to white.

;

PDF Automation Station
Community Expert
Community Expert
July 3, 2025

Set the fill color the way you want it then run the following script in the console:

this.getField("Button1").fillColor;

It will return RGB, plus 3 numbers you can use to replace the 3 numbers in the square brackets in your script.