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

My form colorfill javascript isnt working as I had hoped? Is it not possible?

New Here ,
May 18, 2016 May 18, 2016

I have been looking at similar form fill color issues on the forums but my problem is just a little bit different.  My form fill only changes color when I have it selected.  I am trying to set up a javascript to change the color based on a certain value and to have that color view-able at all times as a way for a boss to quickly see if anything is red.

I found another blog that suggested using a script and I tailored it to my needs below:

I have it input in the actions based on a mouse exit, I have tried putting it in validation but it doesn't work completely when I do that.

var f = this.getField("MX STATUS");

if (f.value == "FMC")

{

    f.fillColor = color.green;  

}

if (f.value == "PMC")

{

    f.fillColor = color.yellow;  

}

if (f.value == "NMC")

{

    f.fillColor = color.red;  

}

This only kind of works, as I stated above, when I input the value the form will change but as soon as I leave and enter another form area it will go back being blue.  I think I will need a way to have it go back to blue if an entry is erased as well. 

I am also worried that I will need some way to only accept these three entries and nothing else.  Lastly I would idealy want a "overall MX status" field to change color based on a combination of values from all of the "MX Status".  I only have a basic understanding of C++ from an elective class I took in 2005.  I dont know if I am expecting too much from javascript or if I just dont know quite how to do it.  Thank you for looking into this!

I am using Adobe Acrobat XI ver: 11.0.13

jiub

TOPICS
Acrobat SDK and JavaScript , Windows
527
Translate
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 , May 18, 2016 May 18, 2016

As was already mentioned, that is very likely a function of the field highlighting. Because of that (and because I do not like my forms to change a user's default settings), in my forms, I modify both the background color and the border color. The background may get covered up by the field highlight color, but the border color will remain visible. This is not quite as "in your face" as the background color, but if you educate your users, the border color will be just as effective as the backgrou

...
Translate
Community Expert ,
May 18, 2016 May 18, 2016

Go to Edit-Preferences-Forms and disable the fields highlighting option.

Translate
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 18, 2016 May 18, 2016

As noted you may have the field highlighting on or the required field highlighting on. This is a user application setting so if you are sendig this form to others you will either need to explain to them how to turn off these features or use JavaScript within the form to turn them off and then restore the user's original settings upon closing.

Translate
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 ,
May 21, 2016 May 21, 2016
LATEST

Thanks for the response, how does one code the document to disable field highlighting and then ensure its turned back on for the user after they exit?

Translate
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 ,
May 18, 2016 May 18, 2016

As was already mentioned, that is very likely a function of the field highlighting. Because of that (and because I do not like my forms to change a user's default settings), in my forms, I modify both the background color and the border color. The background may get covered up by the field highlight color, but the border color will remain visible. This is not quite as "in your face" as the background color, but if you educate your users, the border color will be just as effective as the background color. You can change the border color using the "strokeColor" property:

  f.fillColor = color.green;

  f.strokeColor = color.green;

Translate
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