Skip to main content
Lyle_Worsley
Participating Frequently
July 13, 2021
Answered

Change color of radio button after selection

  • July 13, 2021
  • 2 replies
  • 3977 views

I have a radio button named PF T5 STEP A with three choices of Pass Fail N/A.  I am trying to have the background color of all three choices to be red by default and when one of the choices are selected, all three choices turn white.  I am fairly new to javascript and have looked for any other posts with something like this and I can't find anything I can try to manipulate to what I need.  Appriciate any help.

This topic has been closed for replies.
Correct answer Nesa Nurani

There is couple of ways to achive that. If you won't be reseting radio buttons then set them to be red manually and put this code as "Mouse UP" -> "Run javascript" under "Action" tab in all 3 buttons:

event.target.fillColor = color.white;

 

If you will be reseting buttons or you want to automate process, create text field and make it hidden then put this script in text field under "Calculate" tab -> "Custom calculation script":

this.getField("PF T5 STEP A").fillColor = this.getField("PF T5 STEP A").value == "Off" ? color.red : color.white;

 

 

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
July 13, 2021

There is couple of ways to achive that. If you won't be reseting radio buttons then set them to be red manually and put this code as "Mouse UP" -> "Run javascript" under "Action" tab in all 3 buttons:

event.target.fillColor = color.white;

 

If you will be reseting buttons or you want to automate process, create text field and make it hidden then put this script in text field under "Calculate" tab -> "Custom calculation script":

this.getField("PF T5 STEP A").fillColor = this.getField("PF T5 STEP A").value == "Off" ? color.red : color.white;

 

 

Lyle_Worsley
Participating Frequently
July 14, 2021

Thank you Nesa.  Both your solutions worked!  The code with the ability to reset is the option I needed.

Amal.
Legend
July 13, 2021

Hi Lyle_Worsley

 

Hope you are doing well and sorry for the trouble. As described you want to change the background color of the radio buttons when selected.

 

The workflow that you are trying to achieve is possible using the JavaScript. For more information please check the help page https://acrobatusers.com/tutorials/javascript_console/

 

Hope it will help

 

Regards

Amal