4 Replies Latest reply on Feb 27, 2014 2:08 PM by Efe

    Script for Form Field Fill color

    Efe

      Hello everyone,

       

      I've opened a different discussions with lots of questions but now I've managed to do some of them. I've still got some questions.

       

      Questions:

       

      1.     I have a few fillable boxes in the pdf. I want their fill colors to change according to the input. I'll just enter A or B or C as input.

       

      When:

      A= 212,222,77

       

      B= 255,209,5

       

      C= 237,28,79

       

      Colors should fill the box. How do I do that ?

       

       

      2.     I'll make calculations with those fields. So I should assign numbers to letters. It should be A=1, B=2, C=3. How can I code that?

       

      I appreciate your help, thanks!

       

      Acrobat Professional XI

        • 1. Re: Script for Form Field Fill color
          George_Johnson MVP & Adobe Community Professional

          For #1, are those supposed to be the RGB values that you want to set the fill color to? Even then, it's not clear to me what you want to do exactly.

           

          For #2, it's not clear to me what you mean either. If you provide more information, we can probably help.

          • 2. Re: Script for Form Field Fill color
            Efe Level 1

            Hi George,

             

            Thanks for your help.

             

            I've managed that situation but come up with new problems.

             

            There's a text box in pdf form. When I write A to the box, I want the fill colour of the box to green, but that RGB above. When I write B and C fill color got to turn the colours I've stated above like 'A'.

             

            I've written a javascript. It works but I used the default green red yellow colours of javascript, I couldn't manage to do it in RGB codes.

             

            Here is the code, I've also written (copy pase of course) a code to limit the characters can be put into box with "A", "B", and "C" and capitalization of them. The strings about colours I've written starts with var vcolor = event.value;

             

            var alphaNumericPatt = /^[a-cA-C]*$/;

            event.rc = alphaNumericPatt.test(event.value);

            if (event.value!=null && event.value!="") {

             

                 event.value = event.value.substr(0,1).toUpperCase();

             

            };

             

            {

             

            var vcolor = event.value;

            if (vcolor == "") this.getField('box1').fillColor = color.transparent

            else if (vcolor == "A") this.getField('box1').fillColor = color.blue

            else if (vcolor == "B") this.getField('box1').fillColor = color.black

            else if (vcolor == "C") this.getField('box1').fillColor = color.red

            else this.getField('box1').fillColor = color.transparent;

            }

            • 3. Re: Script for Form Field Fill color
              George_Johnson MVP & Adobe Community Professional

              As an example, for RGB value of 212, 222, 77, the code would be

               

              this.getField('box1').fillColor = ["RGB", 212/255, 222/255, 77/255];

               

               

              For more info: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.260.html

              1 person found this helpful
              • 4. Re: Script for Form Field Fill color
                Efe Level 1

                Sir, you've made my day. Thanks a billion!

                 

                I've been into that link and dozens of more links but I didn't see anywhere that I've to write colours like 212/255. I just write 212,222,77 etc.

                 

                Anyways, thanks a lot, really.