• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Percentage Color Change

New Here ,
Apr 19, 2018 Apr 19, 2018

Copy link to clipboard

Copied

Ok i am setting a script that i need it to calculate a percentage. if the percentage is over 30% it needs to go to red, if it's below it can stay in black.  i'm going off a V3/V4

V3-Payment

V4-Income

any ideas on how to get this setup for red?

This is what it's using right now with the Field Properties Format being Set to Percentage

(function () { 

 

    // Get the field values, as numbers 

    var v3 = +getField("payment").value; 

    var v4 = +getField("ApplicantsTotalNetIncome").value; 

    var v = v3 / v4;

   

    if (!isNaN(v) && v4 != 0) { 

        event.value = v; 

    } else { 

        event.value = ""; 

    } 

 

})(); 

Views

1.4K

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
LEGEND ,
May 21, 2018 May 21, 2018

Copy link to clipboard

Copied

If you're trying to change the textColor and fillColor properties as mentioned many times in these forums. Here's a random post.

Votes

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
Community Expert ,
Jun 28, 2018 Jun 28, 2018

Copy link to clipboard

Copied

LATEST

Change this part of the code:

if (!isNaN(v) && v4 != 0) {

    event.value = v;

}

To this:

if (!isNaN(v) && v4 != 0) {

    event.value = v;

    event.target.textColor = (v>0.3) ? color.red : color.black;

}

PS. For future questions about scripts in Acrobat you'll be better off using this forum: JavaScript

Votes

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