These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

If...then statements involving changing color

skotter623
Registered: Jun 14 2007
Posts: 12

I am creating a survey using Adobe Livecycle forms and I have a row in which the surveyer must have things add up to 100%. I don't want an error message to come up if the row does not add to 100, but I would like the total box to turn different colors depending on the percentage. I figure it is just an if then statement, but I cannot get it to work. Thanks a lot.

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You could do this at the end of the calculation script, and yes you use an if-then statment

if(nPercent

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Let's try this again. My answer got eaton.

if(nPercent < 0.5)this.fontColor = "256,0,0"; // redelse if(nPercent < 0.75)this.fontColor = "256,256,0"; // yelloelse if(nPercent < 1)this.fontColor = "0,0,256"; // blueelsethis.fontColor = "0,256,0"; // green [code]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Queue
Registered: Apr 27 2009
Posts: 22
Bump to the top!

thomp, I've tried out a variation on this theme and can't seem to get it to fire.

Basically, depending upon what's entered in a text field, I'd like to change the fill color. Here's what I've got so far:

if(form1.Page1.ProjectStatus.ProStatusGroup.txtRating1.rawValue = "G")
this.fillColor = "0,255,0"; // Green
else if(form1.Page1.ProjectStatus.ProStatusGroup.txtRating1.rawValue = "Y")
this.fillColor = "255,255,0"; // Yellow
else if(form1.Page1.ProjectStatus.ProStatusGroup.txtRating1.rawValue = "R")
this.fillColor = "255,0,0"; // Red
else if(form1.Page1.ProjectStatus.ProStatusGroup.txtRating1.rawValue = "P")
this.fillColor = "255,0,255"; // Purple
else if(form1.Page1.ProjectStatus.ProStatusGroup.txtRating1.rawValue = "B")
this.fillColor = "0,255,255"; // Blue
else
this.fillColor = "149,149,149"; // Gray

When I test it out, the JavaScript Console gives me this note:

"fill is not defined"

Any clues?

[I'm using Adobe LiveCycle Designer ES and viewing the form in Acrobat Pro 9.]
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You are using LiveCycle Designer and taht does not support the Acrobat JavaScript 'fillColor' propertry. According to the LiveCycle Designer Scripting reference you sould use 'xfa.form.Form1.NumericField1.fillColor', adjusted as needed for your field.

Reference_Syntax.fillColor = "[0-255], [0-255], [0-255]"

Have you defined 'this'?

You are asking a new question and should start a new post.

George Kaiser

Queue
Registered: Apr 27 2009
Posts: 22
Ah, thank you for the clarification, gk!

I will certainly make a new post shortly.