Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


If/Then statement between 3 fields.

Community Beginner ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

All, I have the following fields; TC(total cost), MEL$, and SC. If TC >MEL$, I would want "EXCEED MEL" to populate the SC field in bold red font.

 

Thanks for everyones assistance in advance.

TOPICS
JavaScript

Views

556

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 , Jun 15, 2021 Jun 15, 2021
Use this as a calculation script in the SC field (not tested): if (Number(this.getField("TC").value) > Number(this.getField("MEL$").value)) { event.target.textColor = color.red; event.target.textFont = font.HelvB; } else { event.target.textColor = color.black; event.target.textFont = font.Helv; } Available colors: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJS/color_properties.htm?rhhlterm=textcolor&rhsyns=%20 Available fonts: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJS/Field_properties.htm?rhhlterm=textcolor&rhsyns=%20#XREF_11104_textFont

Likes

Translate

Translate
Enthusiast ,
Jun 14, 2021 Jun 14, 2021

Copy link to clipboard

Copied

Is normaly "SC" field not in bold and red color?

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
Community Beginner ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

No it is not. I will be adding other codes at a later date that will remain black.

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
Adobe Community Professional ,
Jun 15, 2021 Jun 15, 2021

Copy link to clipboard

Copied

Use this as a calculation script in the SC field (not tested):

 

if (Number(this.getField("TC").value) > Number(this.getField("MEL$").value)) {
event.target.textColor = color.red;
event.target.textFont = font.HelvB;
}
else {
event.target.textColor = color.black;
event.target.textFont = font.Helv;
}


Available colors: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJS/co...

 

Available fonts: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJS/Fi...

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
Community Beginner ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

Thanks for this script. It works to bold the text but does not change font color.

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
Community Beginner ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

LATEST

Thanks JR Boulay. It is working now. I re-copied and pasted your script and it started working.

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