Skip to main content
Known Participant
Jun 22, 2018 3:33 PM UTC
Answered

Javascript code: , changing backround color of text field - on/off

Hello there,

Maybe you can help with some Javascript code::

I would like to add a javascript code to a check box: so that with activation of the box (first click) the color of an associated text field

changes from white to red, and with deactivation (second click) the color of the text field changes back again fra red to white.

The text color, black, remains constant. It is like making an on/off switch to the backround color of the text field.

If there is a javascript geni out there who can help this uneducated man with a couple of lines of javascript, I would be foreever thankful.

A reference to an on/off function in javascript would also be deeply  appreciated. Using acrobat pro DC, or v.9 windows

I am a beginner with javascript, and  have just started to learn this miraculous progammering language with serious effort..

Many thanks.

Michael H (Copenhagen DK)

This topic is closed to new replies. Start a new post to keep the conversation going.
Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Dec 12, 2020 11:13 PM UTC

As checkbox MouseUp event add this code:

this.getField("textfield 1").fillColor = event.target.value != "Off" ? color.red : color.white;

4 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
Dec 12, 2020 11:13 PM UTC

As checkbox MouseUp event add this code:

this.getField("textfield 1").fillColor = event.target.value != "Off" ? color.red : color.white;
Translate
jydskAuthor
Known Participant
Dec 13, 2020 3:09 PM UTC

Nesa

Many thanks for your solution. More than adequate to solve this problem. Excellent work.

Best regards

Mike H

Translate