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

Dropdown menu in different colors

Community Beginner ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

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

TOPICS
Create PDFs , Edit and convert PDFs , PDF forms , Standards and accessibility

Views

3.2K

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 , Sep 01, 2020 Sep 01, 2020

Use the script without the first line as validation script.

Votes

Translate

Translate
Community Expert ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Where does you use the script?

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

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!

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

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

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 ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

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.

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 ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

Use the script without the first line as validation script.

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 ,
Sep 02, 2020 Sep 02, 2020

Copy link to clipboard

Copied

Thank you! It worked

Never not learning 

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Hi,

 

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

 

BarlaeDC_0-1598887175764.png

 

Regards

 

Malcolm

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

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

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Thank you Nesa

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Hi Malcom,

 

The check value is on, changed the orange to magenta, but it's not working.

keep thinking about it, but can't see the problem.

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

There's also no color.magneta object. You can't just invent stuff and expect it to work...

 

What's the point of the first line, though? Do you want the value of this field to always be the same as another field ("Dropdown93")? If so, why make it a drop-down field? Just use a simple text field.

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

This code is working for me:

if (event.value=="W1")

event.target.fillColor = color.red;

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

event.target.fillColor = color.magenta;

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;

use it as custom calculation script

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

This part of it is not needed:

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

event.target.fillColor = color.transparent;

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

PS. It's better to use it as a validation script, since you're not actually setting the value.

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 ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

I still have a lot to learn, so thank you for helping me.

Working with simple text would be great, but would take the people who use the form a ot of time filling it in. 

So, I'll try the script that Nesa send and will get back to you with an answer.

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 ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

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? 

 

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 ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

Place it as a Validation script.

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 ,
Oct 26, 2023 Oct 26, 2023

Copy link to clipboard

Copied

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. 

 

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 ,
Oct 26, 2023 Oct 26, 2023

Copy link to clipboard

Copied

LATEST

You can use following color spaces:
Transparent, Gray, RGB, or CMYK

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