8 Replies Latest reply on Jul 8, 2009 6:27 AM by HarrisFR

    PDF form drop down box, hides / shows fields

    Matt_Crook

      Hi

       

      I need a bit of help

       

       

      I need to be able to have a drop down box with 5 options.

       

      Depending on what is selected I want to show several boxes relating to that selection.

       

      i.e If 'option three' is selected I want to be able to show BOX 3A BOX3B etc.

       

      If something else is selected I need the script to hide these boxes and show boxes that are relvant to the new selection.

       

      Hard to explain but hope it is possible with javascript.

       

      Thanks in advance

        • 1. Re: PDF form drop down box, hides / shows fields
          HarrisFR Level 1

          There a very cool sample form that does just that.  It really helped me do something similar in a form I'm working on.http://www.acrobatusers.com/sites/default/files/gallery_pictures/Siri_Khalsa_DHS-0000-ENG. pdf

           

          Hope this helps you.

          • 2. Re: PDF form drop down box, hides / shows fields
            gkaiseril MVP & Adobe Community Professional

            That form sample is a LiveCycle Designer form and use use dynamic pages.

             

            For Acrobat you can set the 'Commit the selected value immediatly' and use the following 'Custom keystroke' script:

             

            // hide all fields to be processed by combo box
            this.getField('Text1').display = display.hidden;
            this.getField('Text2').display = display.hidden;
            this.getField('Text3').display = display.hidden;
            // lock the fields
            this.getField('Text1').readonly = true;
            this.getField('Text2').readonly = true;
            this.getField('Text3').readonly = true;

             

            switch (event.value) {
            case 'Box 1':
            // action for selection 1 value
            // show and unlock fields for option 1
            this.getField('Text1').display = display.visible;
            this.getField('Text1').readonly = true;
            break;

            case 'Box 2':
            // action for selection 2 value
            // show and unlock fields for option 2
            this.getField('Text2').display = display.visible;
            this.getField('Text2').readonly = true;
            break;

            case 'Box 3':
            // action for selection 3 value
            // show and unlock fields for option 3
            this.getField('Text3').display = display.visible;
            this.getField('Text3').readonly = true;
            break;

            default:
            // action for all other values
            break;
            }

            • 3. Re: PDF form drop down box, hides / shows fields
              HarrisFR Level 1

              True I use LiveCycle to create my forms, but if using Acroforms I'm sure this is great.  I have saved your code as a back up.

              • 4. Re: PDF form drop down box, hides / shows fields
                gkaiseril MVP & Adobe Community Professional

                The example is adding entire pages. This can be done in AcroForoms with the 'template' object, but any form using this object can not be used by end users with Reader, one needs Acrobat.

                 

                Just a note, this forum is for Acrobat JavaScript. There are a number of forums specifically for the LiveCycle product and that includes a forum for LiveCycle Designer. It is best not confuse these two different products.

                • 5. Re: PDF form drop down box, hides / shows fields
                  HarrisFR Level 1

                  I'm sure you know a lot more about it than I, but I was able to use that document as a sample and in LiveCycle create the following script that does just what I want it to do without creating new pages:

                  ----- F.P1.ReturnCheck.ReturnCk::mouseUp - (FormCalc, client) --------------------------------------

                  if ($.rawValue == 1) then
                    F.P1.CheckNotation.presence    = "hidden"
                       F.P1.SpecialHandlingSlip.presence    = "visible"
                     F.P1.SepChecksForm.presence = "hidden"
                  else
                  F.P1.CheckNotation.presence    = "visible" 
                  endif

                   

                  ----- F.P1.ReturnCheck.MailCk::mouseUp - (FormCalc, client) ----------------------------------------

                  if ($.rawValue == 2) then
                    F.P1.CheckNotation.presence    = "visible"
                       F.P1.SpecialHandlingSlip.presence    = "hidden"
                     F.P1.SepChecksForm.presence = "hidden"
                  else
                  F.P1.CheckNotation.presence    = "hidden" 
                  endif

                   

                  ----- F.P1.ReturnCheck.SeperateCks::mouseUp - (FormCalc, client) -----------------------------------

                  if ($.rawValue == 3) then
                    F.P1.CheckNotation.presence    = "hidden"
                       F.P1.SpecialHandlingSlip.presence    = "hidden"
                     F.P1.SepChecksForm.presence = "visible"
                  else
                  F.P1.CheckNotation.presence    = "visible" 
                  endif

                   

                  Sometime you just need a running start and it kicks the mind into gear.  Not saying you aren't right, was just sharing what helped me.  Any help you can provide with my problem.  See post re adding text to a submit by email button.

                  • 6. Re: PDF form drop down box, hides / shows fields
                    gkaiseril MVP & Adobe Community Professional

                    FromCalc script does not work in AcroForms. Just look at the syntax and the properties of the scripts posted.

                     

                    LiveCycle Designer JavaScript is also different from AcroForms JavaScript and is not a one to one translation.

                     

                    Please do not confuse users trying to learn AcroForms JavaScript with LiveCycle Designer's scripting languages

                     

                     

                    .

                    • 7. Re: PDF form drop down box, hides / shows fields
                      HarrisFR Level 1

                      Gosh, I know his original message mentioned Java, but this forum is about scripting period.  It doesn't say just Acroforms or LiveCycle specific.  I was offering an option that worked for me.  Isn't that the purpose of user forums to share what has worked.  IF he can or is using LiveCycle this is a valid option.  Maybe I'm reading too much into your response, but it was offputting to me.  I've read your posts before and you share good tips so I'm not sure where that's coming from.  I saved your tip as well for if and when I need to use Java, but the sample document I provided is a good sample and the FormCalc script I shared also works IF you are using LiveCycle.  I included both those caveats in my post.  I'm just astonished that in the month I've been on this forum I've gotten more input on this than any request for assistance with problems scripting I'm having yet.

                       

                      WOW.  I guess newbies aren't welcome.

                      • 8. Re: PDF form drop down box, hides / shows fields
                        HarrisFR Level 1

                        Well GK - I apologize.  I stand corrected this forum is specifically for Acrobat Scripting.  There is a seperate forum for LiveCycle Designer, but it isn't specific to scripting.  However I have use tips from this forum successfully in LiveCycle, but you are correct the opposite will not always work.

                         

                        When you are wrong you are wrong and I apologize if I confused anyone.  I was just trying to be helpful.  I'll repost my questions in the Designer forum.