Copy link to clipboard
Copied
Hello, what I'm trying to do is change the background color of text fields based on a number in an array that matches with the name of the text field in my pdf. The numbers are 0 to 100. So if it is the number 0, it matches with one of the array elements then colors the background based on the first element. Here is the code I'm working on and I can't seem to get it to change the color, any advice on what I could do to make it work?
Thanks
Brian
var colors = [
['blue', 99,98,95,94,91,90,89,80,29,20,19,18,13,12,11,10,9,8,5,4,3,2,1,0],
['green', 25,17,16,15,7,6],
['brown', 24,14],
['red', ],
];
for (var x = 0; x < 100; x ++)
{
for (var i = 0; i < colors.length; i++){
for (var j = 0; j< 100; j++){
if (colors[i][j] = x){
getField(getNthFieldName(x)).fillColor = color.colors[i][0];
}
}
}
}
Copy link to clipboard
Copied
Check the Javascript console for errors.
Copy link to clipboard
Copied
The code is a bit of a mess, and contains errors. So the fields are named "0" to "100"?
Copy link to clipboard
Copied
Actually sorry, the fields are 0 to 99. Sorry I'm trying to patch together a few examples I saw. If i put in
getField(getNthFieldName(x)).fillColor = color.blue;
it works and turns all the fields blue.
Brian
Copy link to clipboard
Copied
How many fields have you in the document?
Copy link to clipboard
Copied
You should not be using getNthFieldName for this. Simply access the field directly, like this:
this.getField(x)