3 Replies Latest reply on Jan 12, 2011 12:42 PM by try67

    Continuation of Field Shift Question

    19Ramon75 Level 1

      This is a continuation of my previous question which was answered.  Using the rect property, I am able to move a field horizontally or vertically based on the value of a radio button (yes/no).  If Yes, I want to shift a specific field down.  If No, I keep the field in its original position.  The problem I am encountering is when a user toggles between Yes and No.  The specific fields are shifted down due to the radio button value being Yes and when the value is changed to No, the fields remain in the new position.  Is there a way to Setthe X,Y coordinates of a field using rect or rectangle?  Did some research but can't figure it out.


      Thanks

       

       

       

       

       

       

        • 1. Re: Continuation of Field Shift Question
          try67 MVP & Adobe Community Professional

          You didn't need to open a new thread for this.

           

          You already know how to set the rect property, don't you? In the code you

          posted in your other thread you did just that. So what aren't you able of

          doing?

          • 2. Re: Continuation of Field Shift Question
            19Ramon75 Level 1

            Out of curiosity, instead of opening a new thread, should I have just replied to the original thread?

             

            The problem is when a user toggles through the Yes and No values on the radio button.  Ideally, the user would only select one or the other.  If so, my script using rect would move the fields down if yes is selected and keep the fields in their original position if no is selected.  However, if a user selects yes, then changes their selection to no, the fields will stay in the new position and not revert to the original position.

             

            I wanted to see if there was a way to actually set the rect properties to actual X,Y coordinate values so that when Yes is selected, the fields move to a specific position and when No is selected, the fields move to a specific position.  I am using part of a script I found in the reference guides and my lack of knowledge of this script property is leading to my confusion.

             

            The code I'm using is:

             

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

            By changing the "else" part of the script, I can have the field move up (+= 100) if No is selected after Yes.  The problem with adding that to the script is if a user selects No first, the field will move up.

             

            Additionally, I thought I could avoid a lot of the headache here by marking either Yes or No as the default value but my form also has a reset button and when the form is reset, the fields move either up or down depending on the last value.

             

            Is there a way to set the coordinates to specific values?  My script is using the fields current position to move accordingly.


            Thanks

            • 3. Re: Continuation of Field Shift Question
              try67 MVP & Adobe Community Professional

              Yes, replying to the previous thread would have been better, I think.

               

              Instead to changing the values of the fields incrementally, you can just

              give them a number.

              So if you want to set the upper left corner of the rect to the point

              , just so this:

               

              aRect[0] = 100;

              aRect[1] = 100;