Skip to main content
Participating Frequently
March 23, 2022
Answered

Change text color of text in field when checkbox is selected

  • March 23, 2022
  • 2 replies
  • 5444 views

Hi 

I am new to Adobe Prepare Form and could use som help. 

I have a field with text and a checkbox to go with the text in that field. 

I would like the text in the field to turn red when the checkbox is selected. 

I suppose this can be done in Check Box Properties > Actions > Mouse up + Run a JavaScript

However, I have never used JavaScript before, so how do I do this? 

 

Please see the attached for clarification. 

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

Use same script just change "textColor" to "fillColor" and change colors (color.white(change 'white' to 'transparent' if you wish field to has no color) and color.yellow).

If you wan't different shade of yellow use RGB colors instead, for example:

if you want lemon yellow RGB code would be 255 247 0 so instead of color.yellow use this ["RGB", 255/255, 247/255, 0/255]

 

2 replies

flygaardAuthor
Participating Frequently
March 24, 2022

Thank you so much. Can you also help me with the javascript for turning the background color of the text field yellow when the checkbox is selected?

 

Please see attached for clarification. 

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
March 24, 2022

Use same script just change "textColor" to "fillColor" and change colors (color.white(change 'white' to 'transparent' if you wish field to has no color) and color.yellow).

If you wan't different shade of yellow use RGB colors instead, for example:

if you want lemon yellow RGB code would be 255 247 0 so instead of color.yellow use this ["RGB", 255/255, 247/255, 0/255]

 

flygaardAuthor
Participating Frequently
March 24, 2022

Thank you so much, that works perfectly! 😄 

Nesa Nurani
Community Expert
Community Expert
March 23, 2022

You can use this at checkbox as you describe it, just change "Text Field" to your actual text field name:

this.getField("Text Field").textColor = event.target.value == "Off" ? color.black : color.red;