Copy link to clipboard
Copied
Hi, I like to create an pdf form with acrobat. for this i have a table with different fields. depending on the value entered in p.e field "A" the text of field "A". "textA" an "textB" should colored red, etc. (like in the table below)
Headline 1 | Headline 2 | Headline 3 |
---|---|---|
A | textA | textB |
1 | text1 | text2 |
I | textI | textII |
I have been using the forums to help me answer the question above and I have managed to create the code below, but it's not working
if (event.value=="a") { event.target.textColor = color.red;
this.getField("textA").textColor = red;
this.getField("textB").textColor = red; }
else if (event.value=="b") { event.target.textColor = color.red; {
this.getField("textA").textColor = red;
this.getField("textB").textColor = red; }
else if (event.value>="0") { event.target.textColor = color.blue; {
this.getField("textA").textColor = blue;
this.getField("textB").textColor = blue; }
else if (event.value=="I") { event.target.textColor = color.green; {
this.getField("textA").textColor = green;
this.getField("textB").textColor = green; }
else if (event.value=="II") { event.target.textColor = color.green; {
this.getField("textA").textColor = green;
this.getField("textB").textColor = green; }
else event.target.textColor = color.black;
Can anyone suggest what I might be doing wrong?
You use too many {
Copy link to clipboard
Copied
Look at the console for errors.
Copy link to clipboard
Copied
You need to be consistent. Why are you using "color.red" in one spot and just "red" in another? The former is correct. The latter isn't.
Copy link to clipboard
Copied
Another thing to be consistent about is how you treat your variables. If it's a string then you need to put double-quotes around it (as you did), but if it's a number then you shouldn't do that, like you did here:
(event.value>="0")
Copy link to clipboard
Copied
thank you for your answers, I took the changes, but still get the syntax-error 7 in line 8
if (event.value=="a") { event.target.textColor = color.red;
this.getField("textA").textColor = color.red;
this.getField("textB").textColor = color.red; }
else if (event.value=="b") { event.target.textColor = color.red; {
this.getField("textA").textColor = color.red;
this.getField("textB").textColor = color.red; }
else if (event.value>=0) { event.target.textColor = color.blue; {
this.getField("textA").textColor = color.blue;
this.getField("textB").textColor = color.blue; }
else if (event.value=="I") { event.target.textColor = color.green; {
this.getField("textA").textColor = color.green;
this.getField("textB").textColor = color.green; }
else if (event.value=="II") { event.target.textColor = color.green; {
this.getField("textA").textColor = color.green;
this.getField("textB").textColor = color.green; }
else event.target.textColor = color.black;
Copy link to clipboard
Copied
You use too many {
Copy link to clipboard
Copied
oh no
thank you all, the code is working correctly now