Copy link to clipboard
Copied
I have used the following code to change the colour of a text field in a PDF form depending on the value entered into that field.
var v = +event.value; {
if (v>=1 && v<=5)
event.target.fillColor = ["RGB",0.537,0.776,0];
}
Can anyone suggest how I can modify this code to change the colour of another field?
I want to change the colour of field "Text453" depending on the number entered into field "RISK"
(I have posted this question on another forum.)
The correct syntax is to put the curly brackets after the if-condition. It works in your case because you only have one line of code associated with it, but it's not good practice. This is how it should look like:
var v = +event.value;
if (v == 1) {
this.getField("Text803").fillColor = ["RGB",0.537,0.776,0];
} else {
this.getField("Text803").fillColor = color.white;
}
Copy link to clipboard
Copied
can i add there be an option up top where they can change the font with pdf form?
where user change font size when filling form.?
Copy link to clipboard
Copied
OK, that's not quite what you described. You can change the color of the entire field based on the selection made in it, but not of an individual item. And no, it's not likely to work on almost any mobile device.