5 Replies Latest reply on Jul 13, 2010 10:53 AM by Dablo_81

    Hidden field does not appear

    Dablo_81

      Hi,

       

      I have created a form that has hidden values attached to radio boxes.  These values are then summed, using the 'value is the sum' calculate tool.  However, there is a lag on the sum function, i.e. I select Ans 1, a (value 5), sum value remains at 0, then I select Ans 2, b (value 2), the sum value is now 5, referring only to the value of Ans 1, not of both.  I could not see a way to rectify this so I thought that it would be logical to add a 'calculate' button at the bottom of the form, which would act as the next action in the step, and when this button was clicked it would also reveal the sum field.

       

      However, although the calculate tool completes it first task, the sum field is not revealed when I click on the calculate button. 

       

      This is what I did:

       

      In the Options tab, I made the export value 1

      In the Actions tab, I added a 'run javascript on mouse up' and added the following code:

       

      if (this.rawValue == "1") {

           (this.getField("FinalScore").presence = "Visible");

      } else {

           (this.getField("FinalScore").presence = "Hidden");

      }

       

      I know the syntax is correct because AcroForms permits me to close the JavaScript Editor box.  Can anyone advise where I am going wrong or if I have missed a step somewhere?

       

      Many thanks.

        • 1. Re: Hidden field does not appear
          try67 MVP & Adobe Community Professional

          Is this an Acrobat form? If so, then there's no such thing as rawValue here.

          Use value instead.

          Also, you can't use "this.value". 'this' points to the document, not the

          field, in this context.

          1 person found this helpful
          • 2. Re: Hidden field does not appear
            Bernd Alheit Adobe Community Professional & MVP

            For AcroForms use the property display. The property presence is for LiveCycle Designer forms.

            1 person found this helpful
            • 3. Re: Hidden field does not appear
              Dablo_81 Level 1

              Thanks Try and Bernd for your comments.  I am using Acrobat 9 pro on my mac to create this acrobat form. I took these and modified my code to read:

               

               

              if (this.getField(Calculate").Value == "1") {

                   (this.getField("FinalScore").display = "Visible");

              } else {

                   (this.getField("FinalScore").display = "Hidden");

              }

               

              Unfortunately this still doesn't work.  I even changed the Visible and Hidden fields to visible and hidden in case they were case sensitive.

              Do you have any other suggestions?  Would it help if I provided the form?

              • 4. Re: Hidden field does not appear
                try67 MVP & Adobe Community Professional

                You should really consult the reference files and not just guess what the

                correct syntax is.

                display is not a string property, but an enum. You can use the following

                values for it:

                display.hidden

                display.visible

                display.noPrint

                display.noView

                 

                Also, JS is case-sensitive. Use value, not Value.

                • 5. Re: Hidden field does not appear
                  Dablo_81 Level 1

                  Thanks again Try.  Using what you said, and also another search online, I rewrote my script to:

                   

                  var Final = this.getField("FinalScore");

                   

                  if (this.getField("Calculate").value == "1")

                       Final.display=display.visible;

                  else

                       Final.display=display.hidden;

                   

                  My form is now complete and ready to be distributed.

                  Thanks again for your patience.

                   

                  Any good books you recommend for studying javascript for acrobat?