Skip to main content
Participating Frequently
August 31, 2020
Answered

Dropdown menu in different colors

  • August 31, 2020
  • 19 replies
  • 6549 views

Hi, 

Being a beginner at Javascript and have been looking and searching for the right code. 

I really hope that you can help me.

 

I have created a fillable PDF with a dropdown menus. The dropdowns have 4 options and want each option to result in a color.

This is the script I currently have been working on and saw that a similair problem somewhere, but their where no problems there.

 

Script: 

event.value=this.getField("Dropdown93").value;

if (event.value=="W1")

event.target.fillColor = color.red;

else if (event.value=="W2")

event.target.fillColor = color.orange;

else if (event.value=="W3")

event.target.fillColor = color.yellow;

else if (event.value=="(leeg)")

event.target.fillColor = color.transparent;

else

event.target.fillColor = color.transparent;

 

The dropdownboxes and background colors (of the boxes) are all red and do not change color. It doesn't matter which result I pick. It stays red. Something is wrong, but do not know what. 

 

I will be very greatfull if someone could help me with this.

 

Thank you very much!


Arti

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Bernd Alheit

At first I wrote is as a validation, but now I have to think about it.

Nesa (posted below) to have one with a calculation and I am still in a learning phase. So today, at this point, not knowing what to do. But still want to learn to do this correctly.

But have to create a calculation for this form.


Use the script without the first line as validation script.

19 replies

Participant
June 30, 2022

Hi everyone, I need to do the same but I'm confused as to which tab on the dropdown list the code belongs? Does it go into Format? 

 

try67
Community Expert
Community Expert
June 30, 2022

Place it as a Validation script.

Participant
October 26, 2023

Hi all, I need to create a RAG colour system using corporate colours in a dropdown list for the user to select next to some text they need to insert. I have tried inserting the code and using corporate colours but sometimes reverts to rgb colours and in some cases Amber reverts to red and the colours don't stay the go transparent when deselected. I'm clearly doing something wrong. Is there a step-by-step guide/video on how to do this please. 

 

BarlaeDC
Community Expert
Community Expert
August 31, 2020

Hi,

 

Do you have the "Commit selected value immediately" check or not ?

 

 

Regards

 

Malcolm

Nesa Nurani
Community Expert
Community Expert
August 31, 2020

There is no "color.orange" use rgb code for orange color or use some other color.

With ArtiAuthor
Participating Frequently
August 31, 2020

Thank you Nesa

Bernd Alheit
Community Expert
Community Expert
August 31, 2020

Where does you use the script?

With ArtiAuthor
Participating Frequently
August 31, 2020

Hi Bernd,

I used the script on the dropdown menu. All of the menu's contain the same possibility, W1 or W2 or W3 or (leeg).

The dropdown menu's all have a different numbers. I could send a sheet, if it makes it easier?

 

Thank you!

Bernd Alheit
Community Expert
Community Expert
August 31, 2020

Does you use the script at validation, calculation, or what?