if/then statement with result also color coded

Explorer ,
Aug 18, 2019 Aug 18, 2019

Copy link to clipboard

Copied

I have created a form in which there is a text field "TotalPoints" that is a calculated value of five fields above it.

In another field, I want to show the rating description based on the number of points:

     If TotalPoints >9, then "HIGH"  (in red letters) 

     else If TotalPoints <7 then "LOW" (in green letters)

     else "MEDIUM"  (in orange letters)

How do I do this??

TIA ~ Michelle

TOPICS
PDF forms

Views

250

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Aug 19, 2019 Aug 19, 2019
You can use the following code as the custom calculation script of the "description" field:var totalPoints = Number(this.getField("TotalPoints").valueAsString);if (totalPoints<7) {    event.value = "LOW";    event.target.textColor = color.green;} else if (totalPoints<=9) {    event.value = "MEDIUM";    event.target.textColor = ["RGB", 1, 0.64, 0];} else {    event.value = "HIGH";    event.target.textColor = color.red;}

Likes

Translate

Translate
Adobe Community Professional ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

You can use the following code as the custom calculation script of the "description" field:

var totalPoints = Number(this.getField("TotalPoints").valueAsString);

if (totalPoints<7) {

    event.value = "LOW";

    event.target.textColor = color.green;

} else if (totalPoints<=9) {

    event.value = "MEDIUM";

    event.target.textColor = ["RGB", 1, 0.64, 0];

} else {

    event.value = "HIGH";

    event.target.textColor = color.red;

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

Just amazing!  Thank you so much.  Where can I find a list of color codes to use?  This "color.green" is a bit to light, but when I look at the codes on the text color properties in the form, the RGB color for this green is 0, 255, 0.

UPDATE**  I figured it out, saw another post on converting RGB colors for work in JS (basically, color # divided by 255).  I also realized that I didn't take into account when the form is blank or has a 0 result.  In those times, the green LOW was appearing since it was <7,  Using your format, I carefully edited to add a <1 condition resulting in a blank " " and removed the color line.       Again, thank you so very much!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 18, 2020 Jun 18, 2020

Copy link to clipboard

Copied

LATEST

Would I do something similar to this if I wanted an if then statement for a subtraction problem? I have a document I converted to a form and it has TotalCharges and TotalCredits. I want to subtract the credits from the charges and put the total on the BalDue field if >=0 and on the Refund line if it is < 0. How would I make the number red and with parenthesis for the refund?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines