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.


Highlighting text within a text field that is determined by custom calculation script-Adobe Acrobat DC

New Here ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

Hello,

I do not have the JavaScript extension in my Adobe so I have been getting around that by using the 'Custom calculation script' calculation on text fields. I got stuck recently and could use some help.

I wrote the script below for a document I am working on. I needed the selection from drop down menu ("A") to auto-populate text into text field ("Text1"). I used this calculation in the ("Text1") field. Each drop down selection has it's own body of text, the script works but I am stuck because now I want the script to highlight and italicize certain words/phrases in each of the auto-populated answers.

var choice = this.getField("A").value;{

if (choice=="COMPANY COVERED")event.value = ("Company is willing to cover $XXXXXX");

else if (choice=="NO CONTRIBUTION")event.value = ("Company is willing to contribute $XXXXXX, to assist with this cost, leaving a balance of $XXXXXX. This balance will need to be paid directly to Company or an approved contractor.  You agree that you will be responsible for the Full Cost of $XXXXXX if we perform the work outlined in this notice and your agreement is canceled by you. Please note Company's offer to contribute financially to your contract cost, only applies to your currently executed system, pricing, and your XXXXXXX payment type.");

else if (choice=="PARTIAL OUT OF POCKET")event.value =("Company will cover $XXXXXX, you will be responsible for covering $XXXXXX.");

else if (choice=="NO ROLL IN AMOUNT")event.value =("You as the customer will be responsible for paying $XXXXXX which cannot be rolled in to your contract");

else if (choice=="ROLL ALL IN")event.value =("Yes $XXXXXX");

else event.value = " ";

}

I want to highlight everywhere the text shows "$XXXXXX" or "XXXXXXX" and I want to italicize where it says "Please note Company's offer to contribute financially to your contract cost, only applies to your currently executed system, pricing, and your XXXXXXX payment type"

Your help is greatly appreciated.

TOPICS
Acrobat SDK and JavaScript

Views

454

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 ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

You can't really highlight text in a form field, but if the field is set for Rich Text (on the Options tab in the Field Properties), then the text color and style can be controlled.

Rich text is a whole advanced scripting topic by itself. It uses the Span object. You can read about it here.

Acrobat DC SDK Documentation

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

Thank you, but I can't seem to get close to what I want.

I am reviewing that link and it looks like it only shows how to make the entire field change text color and style. I just need certain words and phrases within the existing script to change color and style.

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 ,
Feb 22, 2018 Feb 22, 2018

Copy link to clipboard

Copied

LATEST

No, that link is to the "field.richValue" property. This is property that adds rich text to a field with an array of "Span" objects. Each span sets the text styles for a single span of text. Just like HTML. The examples show how it's done, and they do it using multiple spans.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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