Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Change border if checkbox is checked

Community Beginner ,
Jul 03, 2025 Jul 03, 2025

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?

TOPICS
JavaScript , PDF , PDF forms
211
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
3 ACCEPTED SOLUTIONS
Community Expert ,
Jul 03, 2025 Jul 03, 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;
}

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 2025

Try this:

oFld.fillColor=["RGB", 0.749, 1, 0.749];

or this:

oFld.fillColor=["RGB", 191/255, 255/255, 191/255];

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 2025
LATEST

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

}

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 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;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 03, 2025 Jul 03, 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.

;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 2025

Try this:

oFld.fillColor=["RGB", 0.749, 1, 0.749];

or this:

oFld.fillColor=["RGB", 191/255, 255/255, 191/255];

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 03, 2025 Jul 03, 2025

Thank you.  They both worked.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 03, 2025 Jul 03, 2025

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2025 Jul 03, 2025
LATEST

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

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines