Skip to main content
Participating Frequently
March 23, 2022
해결됨

Change text color of text in field when checkbox is selected

  • March 23, 2022
  • 2 답변들
  • 5482 조회

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
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;