Skip to main content
Participant
June 25, 2017
Question

clear the background fill color of radio buttons

  • June 25, 2017
  • 3 replies
  • 3250 views

With mutually exclusive checkboxes - meaning only one can be checked at a time - is it possible to toggle the background fill color with a javascript in the 'Actions' of a checkbox,

event.target.fillColor = event.target.value !== "Off" ? color.red : color.transparent

Is there anything similar that will work with radio buttons. The buttons all begin with no background fill. When selected, they turn a color based on a script.

With the above script, when the specific button is selected, all radio buttons in the group turn red. When the form section is cleared, the background fill remains… This is something to do with the radio buttons being grouped but I am out of ideas of how to get around this. Resetting the entire form does not clear the background colors of radio buttons either.

Any suggestions?

This topic has been closed for replies.

3 replies

JR Boulay
Community Expert
Community Expert
July 13, 2017

Because I thought that it may help you.

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
June 26, 2017
Acrobate du PDF, InDesigner et Photoshopographe
garyw_308Author
Participant
July 12, 2017

Why do you keep posting this. More of an advertisement than a helpful answer.

Inspiring
June 25, 2017

With check boxes and radio buttons you can specify the individual wedgit. See Acrobat Javascript Reference for more information. See the Field object in the Acrobat JavaScript Object Reference.

You may have to write a custom clear form button action in JavaScript that resets the fill color for those fields.

If you clear the form the value of the radio buttons will be "Off" so it appears your default color should be red unless you have the one of widgets in the radio button group set to be checked as the default value.

garyw_308Author
Participant
June 25, 2017

Another follow up.

The field clue was good. I was able to combine that with some reading about fill color and came up with a solution.

As I was trying to reset a section of a form and clear the background colors of the radio buttons...

Created a button

in the action field  added 'Reset a form' and then selected the exact sections I wanted to reset.

additionally I added a 'Run a javascript' and added this bit of code:

var f = this.getField("Sct2");

f.fillColor=color.transparent;       

This works as there are 17 sections in the document... Sct1.   through Sct17.

The code was copied from the action in "Sct2"

this clears all the radio buttons of the left behind fill from the reset action.

Thanks for the initial clue