Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Change Color of Text Field from Drop Down Menu Selection

New Here ,
Mar 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

HI! I want to learn how I can change the color of a text field based on specific selections from a drop down menu. If let's say "Medicaid" is selected from drop down menu field "Insurance Company Name", I would like the text field "Medicaid" to highlight yellow. How can I do that with java script? Thanks!

TOPICS
PDF forms, Windows

Views

2.1K

Likes

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

Adobe Community Professional , Mar 15, 2019 Mar 15, 2019
As the custom calculation script of text field enter the following code:event.target.fillColor = (this.getField("Insurance Company Name").valueAsString=="Medicaid") ? color.yellow : color.transparent;

Likes

Translate

Translate
Adobe Community Professional ,
Mar 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

As the custom calculation script of text field enter the following code:

event.target.fillColor = (this.getField("Insurance Company Name").valueAsString=="Medicaid") ? color.yellow : color.transparent;

Likes

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 ,
Mar 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

You rock! That worked! I have multiple selections that if selected from the drop down I want to change the textfield to yellow. Where would I enter the other selections in your script?

Likes

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
Adobe Community Professional ,
Mar 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

You can do it like this:

var v = this.getField("Insurance Company Name").valueAsString;

event.target.fillColor = (v=="Medicaid" || v=="Something else" || v=="Yet another thing") ? color.yellow : color.transparent;

Likes

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 ,
Mar 15, 2019 Mar 15, 2019

Copy link to clipboard

Copied

Thank you soooooo much! That worked perfectly!

Likes

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 ,
Feb 13, 2020 Feb 13, 2020

Copy link to clipboard

Copied

Hi, I have another question

What should I write if I want to create different colors for different dropdown options? 

Many thanks 🙂

Likes

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 ,
Feb 18, 2020 Feb 18, 2020

Copy link to clipboard

Copied

What should I write if I want to create different colors for different text options?

Likes

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
Adobe Community Professional ,
Feb 18, 2020 Feb 18, 2020

Copy link to clipboard

Copied

Likes

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 ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

Hello, 

Can someone please help me? I have a dropdown menu in PDF forms in which there are 2 options (text) and I want based on the option that someone chooses the text colour to change. How can I code this in java? 

 

Thank you!

Likes

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
Adobe Community Professional ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

LATEST

Well, your inquiry is already addressed here in this thread using Acrobat JavaScript not Java.

 

Acrobat JavaScript is the programming language that the Adobe Acrobat use.

Likes

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