6 Replies Latest reply on Jun 11, 2015 9:41 AM by gkaiseril

    Add a function to my script... Is this what I need? How do I do it?

    michaeln24769708

      Good morning Sportsfans!

       

      I'm a very, very bad programmer. So go easy on me.

       

      I have a PDF form (adobe acrobat XI, not pro) that I have some java script in. I have one box that updates once, and doesn't update again when anything on the form changes. I believe that what I need a function so that any time a drop-down is clicked, the script runs again. How would I do this?

       

      In case it is necessary, the script is here:

       

      //Script to return instructions for filing out form

      if(this.getField("Contact").value=='Select one of the following:'){event.value=''};

      else if(this.getField("YN1").value=='Select one of the following:'){event.value=''};

      else if(this.getField("Section1").value=='DO NOT PROCESS THE TRANSACTION'){event.value='Do Not Process'}

      else if(this.getField("YN1").value=='No'){event.value=' '}

      else if(this.getField("Validator").value==' '){event.value=' '}

      else if(this.getField("YN1").value=='Yes'&&this.getField("YN4").value=='Yes'){event.value='Pro cess The Transaction'}

      else if(this.getField("YN2").value=='No'){event.value='Do Not Process'}

      else if(this.getField("YN4").value=='Yes'){'Process The Transaction'}

      else if(this.getField("YN3").value=='No'){event.value='Do Not Process'}

      else if(this.getField("YN2").value=='Select one of the following:'){event.value='Complete Section III'}

      else if(this.getField("YN3").value=='Select one of the following:'){event.value='Complete Section III'}

      else (event.value='Process the transaction');

        • 1. Re: Add a function to my script... Is this what I need? How do I do it?
          gkaiseril MVP & Adobe Community Professional

          There is no difference in a form being processed by Acrobat Standard or Acrobat Professional. There are differences in the features available for editing scripts. Once the form is created, there are differences between Acrobat, Reader and Mobile apps for processing forms with JavaScript. There are certain JavaScript features not available to Reader and there many more that are not available to mobile PDF reader apps.

           

          Any time any field used in a calculation is updated, the entire pdf is recalculated.

           

          Where have you placed this script?

           

          What should happen if more than one condition is meet?

          • 2. Re: Add a function to my script... Is this what I need? How do I do it?
            michaeln24769708 Level 1

            Ok, then I'm really confused here.

             

            I have 4 text fields, and 5 drop downs. The text fields have script to display differnet strings depending on what is selected in various boxes.

             

            One box does not work. For the ease of the discussion, we'll simplify it to this:

             

            If Dropdown 1 =='yes' and Dropdown 2=='yes', then Text1=='Complete Section II'

            If Dropdown 1=='no', then Text1=='Do Not Process'

            else If Dropdown 2=='no', then Text1=='Have Colleague Do XYZ'

            else if Dropdown 3=='yes' then Text1==' '

             

            And it will not always hold true to the code. Like, it will work for the first one, but then gets stuck somewhere in my code and it just sticks on a particular output even when none of the conditions for that output are met.

            • 3. Re: Add a function to my script... Is this what I need? How do I do it?
              michaeln24769708 Level 1

              And to make this more confusing, I've taken the "Do Not Process" out of the script completely... And it is still showing up. I really have no idea how that is even possible. It is not anywhere in the code, it is not anywhere in the text box default values, it is not anywhere, but there it is.

              • 4. Re: Add a function to my script... Is this what I need? How do I do it?
                gkaiseril MVP & Adobe Community Professional

                The code you provided looks like it is updating one text field using that text field's custom JavaScript calculation or validation option. The value is determined by a couple of dependent selections.

                 

                Now you state you have 5 text fields and each text field has a script that determines what should be displayed in each text field but do not provide the logic needed for each one of those 5 fields. I am assuming each text field has a different set of requirements to be meet for a given message to be displayed.

                 

                Have you tried to open the JavaScript console. and see there are any error messages?

                • 5. Re: Add a function to my script... Is this what I need? How do I do it?
                  michaeln24769708 Level 1

                  No, how do I open the JavaScript console?

                   

                  And yes, I am only updating one at a time. Think of this like an Excel sheet (because it works in Excel)--Cell B15 is has 4 different outcomes depending on the various combinations of what is input into cells A5, A17, and B33. In this case, those three are all drop downs, and B15 is the one I am trying to code.

                  • 6. Re: Add a function to my script... Is this what I need? How do I do it?
                    gkaiseril MVP & Adobe Community Professional

                    You can use the "More tools" in the form editing mode or the combination of the Control/Option key and the "J" key.

                     

                    Since you are updating each text field individually you need to provide the code for each text field.

                     

                    PDF forms and JavaScript are not Excel cells and formulas.

                     

                    It might be helpful you provided a link to a sample form with your code.