Skip to main content
Participating Frequently
March 23, 2022
解決済み

Change text color of text in field when checkbox is selected

  • March 23, 2022
  • 返信数 2.
  • 5480 ビュー

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. 

このトピックへの返信は締め切られました。
解決に役立った回答 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

flygaard作成者
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 Expert解決!
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]

 

flygaard作成者
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;