6 Replies Latest reply on Jan 12, 2011 4:53 AM by 19Ramon75

    Can you use scripting to shift fields?

    19Ramon75

      Is there a way to shift fields up or down using scripting?  Have a form where fields are hidden based on the value of a radio button group.  When the fields are hidden, I want to shift the remaining visible fields up so no gap is present.


      Is this possible?

       

      Thanks

        • 1. Re: Can you use scripting to shift fields?
          try67 MVP & Adobe Community Professional

          Sure, by setting the rect property.

          See more information in the reference files.

          1 person found this helpful
          • 2. Re: Can you use scripting to shift fields?
            19Ramon75 Level 1

            Thanks for the response.  I reviewed the reference guides but I still can't seem to make the existing text box move.  The script I am using is:

             

            if (this.getField("radiobutton").value == "Yes") {
            a.display = display.visible;
            a.Rect[ 0] += 10;
            a.Rect[ 2] += 10;
            } else {
            a.display = display.hidden;
            }

             

            I found the Rect part of this scrip in the reference material.  Can anyone identify where the problem is?

             

            Thanks

            • 3. Re: Can you use scripting to shift fields?
              try67 MVP & Adobe Community Professional

              Javascript is case-sensitive. Use rect, not Rect.

              Also, where are you assigning a value to the variable "a"?

              1 person found this helpful
              • 4. Re: Can you use scripting to shift fields?
                19Ramon75 Level 1

                I assigned the a variable in the beginning.  Below is the actual script I am using.  It is a combination of my original script and the rect script I found in the reference guides:

                 

                var a = this.getField("costs1");
                var b = this.getField("costs1");
                var aRect = b.rect;
                if (this.getField("radiobutton").value == "Yes") {
                a.display = display.visible;
                aRect[0] += 10; // increment first x-coordinate by 10
                aRect[2] += 10; // increment second x-coordinate by 10
                b.rect = aRect; // update the value of b.rect
                } else {
                a.display = display.visible;
                aRect[0] -= 50; // increment first x-coordinate by 10
                aRect[2] -= 50; // increment second x-coordinate by 10
                b.rect = aRect; // update the value of b.rect
                }

                 

                This moves the field left or right depending on the radiobutton value (yes/no).  How do I set it to move it up or down?  Is there a "set" property I should be using for the X and Y coordinates?


                Thanks for the assistance.

                • 5. Re: Can you use scripting to shift fields?
                  try67 MVP & Adobe Community Professional

                  You need to edit the other items in the rect array to move it up or down.

                  From the reference:

                  An array of four numbers in rotated user space that specify the size and

                  placement of the form field. These four numbers are the coordinates of the

                  bounding rectangle and are listed in the following order: upper-left x,

                  upper-left y, lower-right x and lower-right y.

                  • 6. Re: Can you use scripting to shift fields?
                    19Ramon75 Level 1

                    Got it:

                    rect[0]

                    rect[1]

                    rect[2]

                    rect[3]

                     

                    Thanks!!!