Attempting to get conditional formatting to apply immediately

New Here ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

I am stuck at about 90% progress towards my goal. The goal is to have various text elements on a form automatically be updated based on the value selected in a dropdown field on the form. For example, I have a dropdown box with the name "Role". It currently has 2 possible values, "Default" (which is the default value), and "Tester". I also have a text box with the name "Description", which is the object I want to conditionally format based on the value selected in the "Role" dropdown box. I have this working currently, except for one issue: in order to get the formatting on the "Description" text to change, I have to click into that field of the form (only commits when focus shifts to that field). What id like is for the text change to be applied immediately. The text in the Description box is actually going to be static (other than color change), so id rather it just be text rather than a text entry box, however I couldnt get that to work at all which is why its a text field. Currently on my "Description" text field I have a custom calculate script as follows:

 

var role = (this.getField("Role").value);

if (role=="Tester")

{

event.target.textColor=color.blue;

}

else

{

event.target.textColor=color.black;

}

 

And again, the above works, except that it only does so after focus changes to the "Description" field whereas id like it to commit as soon as the option is selected on the "Role" dropdown. I attempted moving the script to be bound to mouse events (mouse enter, mouse exit, etc) on the dropdown instead, but didnt get any better results.

TOPICS
JavaScript, PDF forms

Views

86

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

Most Valuable Participant , Jan 30, 2021 Jan 30, 2021
Make sure to set the option to commit the selected value of the drop-down field immediately. You'll find it under Properties, Options tab.

Likes

Translate

Translate
Most Valuable Participant ,
Jan 30, 2021 Jan 30, 2021

Copy link to clipboard

Copied

Make sure to set the option to commit the selected value of the drop-down field immediately.

You'll find it under Properties, Options tab.

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 ,
Jan 31, 2021 Jan 31, 2021

Copy link to clipboard

Copied

I did find that a while after posting this. I later ran into a different problem (an apparent cap on the number of Cases in a switch), but I think ive worked around that at this point as well. Thanks for replying thuogh!

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
Most Valuable Participant ,
Jan 31, 2021 Jan 31, 2021

Copy link to clipboard

Copied

LATEST

There's no limit to the amount of cases you can add to a switch command. There is one to the length of the script you can input into the internal JS editor of Acrobat, though.

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