2 Replies Latest reply on Jul 7, 2011 8:58 PM by FlacoBee

    Changing the color of a button when clicked to multiple colors

    FlacoBee

      Ive been given the a task of creating a map for a major renovation of our hotel. I have limited experience in Acrobat and scripting so any and all reccomondations would greatly be apprecated.

       

      I need to create a pdf that management can click on a button/check box (just something to cover the room) and be able to cycle though three colors independantly to quickly see what the status is of each room. There are 884 rooms on eight floors. Ive attached a section of one of the floors. Thanks in advance for any help.

       

      Level Four Section.jpg

        • 1. Re: Changing the color of a button when clicked to multiple colors
          try67 MVP & Adobe Community Professional

          So let's say you have a button called "Room1". Set its fill color to red (left most column, center row), and add this code as its MouseUp JavaScript action:

           

          var field = getField("Room1");
          if (color.equal(field.fillColor,color.red))
              field.fillColor = color.green;
          else if (color.equal(field.fillColor,color.green))
              field.fillColor = color.blue;
          else if (color.equal(field.fillColor,color.blue))
              field.fillColor = color.red;

           

          If you need to apply this to many fields, you can create a doc-level script, like so:

           

          function switchColor(fName) {

          var field = getField(fName);
          if (color.equal(field.fillColor,color.red))
               field.fillColor = color.green;
          else if (color.equal(field.fillColor,color.green))
               field.fillColor = color.blue;
          else if (color.equal(field.fillColor,color.blue))
               field.fillColor = color.red;

          }

           

          and then on the MouseUp action of each button you just call the function, with the button's name as the parameter:

           

          switchColor("Room1");

          • 2. Re: Changing the color of a button when clicked to multiple colors
            FlacoBee Level 1

            Perfect. Exactly what I needed. Thanks!