2 Replies Latest reply on Aug 13, 2009 7:23 AM by gkaiseril

    Need a JavaScript for an "If this, show this" situation

    longrenparks

      I'm creating an interactive selection guide in Acrobat using radio buttons and standard buttons. The first field in my form was easy: If they said yes to Question 1 (Q1), the radio button was instructed to show Buttons A1, A2, A3 & A4 in my grid. If they chose no, the radio button was instructed to show Buttons B1, B2, B3, B4 in my grid. This were going along smoothly.

       

      Then, my grid has become more difficult. I need a script that says something like for Question 2,  "If Q1 is A1, show buttons C1, C2, C3, C4. If question 1 is B1, show buttons D1, D2, D3."

       

      I'd appreciate your help.

        • 1. Re: Need a JavaScript for an "If this, show this" situation
          longrenparks Level 1

          I thought I'd attach a file to show my exact problem.

          • 2. Re: Need a JavaScript for an "If this, show this" situation
            gkaiseril MVP & Adobe Community Professional

            It is a little hard without knowing the exact field names and values of each selection. Radio Buttons and Check Boxes have a value of 'Off' when there is not selection also all the buttons or check boxes in an exclusionary group (same name) can have common properties modified by just referring to the common field name.

            From looking at your attached file it appears you want 'C1' shown when 'Q1' is 'Yes' and this is different from what you described.

            For the 'Q1' buttons you have to use the same mouse up script for all 'Q1' buttons to allow for deselecting of a widget and the clearing of the form. I am assuming that 'Q1' has the possible values of 'Yes', 'No', and 'Off'. If after selecting an option for Q1 and then changing that option later will require the completion of the other options fields and the clearing of the initial responses.

             

             

            // establish known initial state - or 'Off'
            this.getField('A1').hidden = true; // hide A1
            this.getField('B1').hidden = true; // hide B1
            this.getField('C1').hidden = true; // hide C1
            this.getField('D1').hidden = true; // hide D1
            this.resetForm(['A1', 'B1', 'C1', 'D1']) // clear values from field A1 and B1
            // answered Q1 yes
            if(event.value == "Yes") {
            this.getField('A1').hidden = false; // show A1
            this.getField('C1').hidden = false; // show C1
            }
            // answered Q1 no
            if(event.value == 'No'){
            this.getField('B1').hidden = false; // show B1
            this.getField('D1').hidden = false; // show D1
            }