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
Copy link to clipboard
Copied
Use the script without the first line as validation script.
Copy link to clipboard
Copied
Where does you use the script?
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!
Copy link to clipboard
Copied
Does you use the script at validation, calculation, or what?
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.
Copy link to clipboard
Copied
Use the script without the first line as validation script.
Copy link to clipboard
Copied
Thank you! It worked
Never not learning
Copy link to clipboard
Copied
Hi,
Do you have the "Commit selected value immediately" check or not ?
Regards
Malcolm
Copy link to clipboard
Copied
There is no "color.orange" use rgb code for orange color or use some other color.
Copy link to clipboard
Copied
Thank you Nesa
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.
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.
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
Copy link to clipboard
Copied
This part of it is not needed:
else if (event.value=="(leeg)")
event.target.fillColor = color.transparent;
Copy link to clipboard
Copied
PS. It's better to use it as a validation script, since you're not actually setting the value.
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.
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?
Copy link to clipboard
Copied
Place it as a Validation script.
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.
Copy link to clipboard
Copied
You can use following color spaces:
Transparent, Gray, RGB, or CMYK

