• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

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)

TOPICS
Acrobat SDK and JavaScript , Windows

Views

727

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 12, 2020 Dec 12, 2020

As checkbox MouseUp event add this code:

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

Votes

Translate

Translate
Community Expert ,
Dec 12, 2020 Dec 12, 2020

Copy link to clipboard

Copied

As checkbox MouseUp event add this code:

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 13, 2020 Dec 13, 2020

Copy link to clipboard

Copied

Nesa

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

Best regards

Mike H

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 20, 2022 Jan 20, 2022

Copy link to clipboard

Copied

This code changes the background color when checked but if you click on something else it goes transparent again even when checked. Is there a way to get it to stay the new color even when you click off of the field?

 

Thank you for any help in advance.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2022 Jan 25, 2022

Copy link to clipboard

Copied

LATEST

That should not be the case. Where did you place the code? Can you share the file in question?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines