JavaScript for radio buttons in Adobe Prepare Form
- April 25, 2022
- 2 replies
- 4270 views
Hi
I could use some help with JavaScript in Adobe Prepare Form.
1)
I have a series of five radio buttons. For each of the five radio buttons there is a corresponding text field.
I would like the corresponding text field to change fill color when the radio button is selected, and then the fill color of the first text field should go back to transparent if the user changes their choice to one of the other radio buttons, and then the text field belonging to the newly selected radio button should change fill color instead.
I can get the text field to change fill color when the radio button is selected, but then when the choice is changed to a different radio button, the fill color in the first text field stays there. Can anyone help me fix the JavaScript to achieve this?
My current Java script to ”radio button, Choice1” is: this.getField("TextField1").fillColor = event.target.value == "Off" ? color.transparent : ["RGB", 253/255, 224/255, 195/255];
And for ”radio button, Choice2” the Javascript is: this.getField("TextField2").fillColor = event.target.value == "Off" ? color.transparent : ["RGB", 253/255, 224/255, 195/255];
And so on for the last three choices of the radio button as well.
But this script only changes the fill color when selecting the radio button (e.g. Choice1). When changing choice to a different radio button (e.g. Choice2) in the series of radio buttons, the fill color of the first text field does not go back to transparent. What is wrong with my script? Please help.
2)
Also, I would like the radio button itself to change fill color when the radio button is selected, and the fill color to go back to transparent again when a different radio button is selected instead. How do I do this?
I know how to do this for check boxes using this script: this.getField("CheckBox1").fillColor = event.target.value == "Off" ? color.transparent : ["RGB", 253/255, 224/255, 195/255];
But this script does not work for radio buttons it seems. Can anyone help fix this script as well?
Please see the attached for clarification.
Thank you.
