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

changing color based on a value range

Explorer ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

Hi All

I'm trying to make a form that changes color based on input from a field. For example, if  my "B" field is 100 then my "actual" field will display the text in red if the number input is in the range of (100*0.95 to 100*0.96)

Here is my attempt but it doesn't seem to work. Any pointers will be awesome thx

 

var lowrange = this.getField("B").value * 0.95;
var highrange = this.getField("B").value * 0.96;
var actual = event.value;

if (actual>=lowrange && actual<=highrange)

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

else
event.target.textColor = [ "G",0];

TOPICS
JavaScript

Views

909

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

Community Expert , Aug 09, 2022 Aug 09, 2022

Works fine for me, too.

Votes

Translate

Translate
Community Expert ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

The code looks fine, but where did you place it, exactly?

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
Explorer ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

I tried to place them both in custom calc and in custom validation script and neither works. It's weird because it works if I just do (actual>=lowrange) but if I add in another range it stopped working. Been playing around with it for a few hours but can't figure out what's wrong

 

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 ,
Aug 08, 2022 Aug 08, 2022

Copy link to clipboard

Copied

Does this field have a calculated value, or one entered by the user? Are there any error messages in the JS Console when you use it? Can you share the file with us?

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
Explorer ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

No calc field (yet) just trying to get the simple version to work first. There is no error

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 ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

Works fine for me. Do you use any other software to open the file? How do you enter a number in 'Actual' field?

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 ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

Works fine for me, too.

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
Explorer ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

I'm using adobe acrobat pro. The number in the "actual" field is entered manually

 

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
Explorer ,
Aug 09, 2022 Aug 09, 2022

Copy link to clipboard

Copied

LATEST

It worked. All I had to do was restart my computer -__-

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