21 Replies Latest reply on Aug 20, 2013 10:25 AM by George_Johnson

    Check boxes / display

    AndyHopkins1965

      I have an order form that customer will fill in quantity of products, the forms totals and add $8 shipping if it is below $400.  There are 3 check boxes that the customer can check.  "Overnight" "2nd Day" and "International" 

       

      Question:  How can I have the "Extra shipping" and 'Total" fields display "We'll Call" (or whatever words) if one of those check boxes has been checked?

       

      thanks

      Andy

       

      MacOS

      Acrobat X Pro

        • 1. Re: Check boxes / display
          MichaelN Level 3

          Hi Andy,

           

          Create a text field with "We'll Call" in it, then make it hidden (Text Filed Properties > General > Form Field Hidden).

           

          Then make this the mouse up script for the "Extra shipping" and "Total" checkboxes:

              

               // Get the value of the check box
               var v = getField("myCheckBox").value;

           

               //If it is off, then hide the text field
               if (v == "Off") {
               this.getField("myTextField").display= display.hidden;    //hide the text field
               }

               else {
               this.getField("myTextField").display= display.visible;     //show the text field
               } 

           

           

          Replace "myCheckBox" with whatever the checkbox name is in your form.

          Replace "myTextField" with whatever the hidden text field name is in your form.

           

          I hope this helps.

          • 2. Re: Check boxes / display
            AndyHopkins1965 Level 1

            MichaelN,

            Thanks so much for taking the time to help.  Here's what I have in the "Mouse Up" -Run a Java Script field.  It's not working yet, do I have something wrong? 

             

            // Get the value of the check box

            var v = getField("overnight").value;

             

            // Get the value of the check box

            var v = getField("second").value;

             

            // Get the value of the check box

            var v = getField("international").value;

             

             

            //If it is off, hide the button

            if (v == "Off") {

            this.getField("WellCall").display= display.hidden;

            }

             

            else {

            this.getField("WellCall").display= display.visible;

            }

            • 3. Re: Check boxes / display
              MichaelN Level 3

              Hi Andy,

               

              You have assigend the same variable "v" to all 3 check boxes. They should have unique variable names.

               

              Use this as the mouse up action for the "WellCall" text field:

               

                  

                   // Get the value of the overnight check box
                   var a = getField("overnight").value;

                   // Get the value of the second check box
                   var b = getField("second").value;

                   // Get the value of the international check box
                   var c = getField("international").value;

                   //make WellCall field visible if any of the check boxes are on
                   if (a == "On" || b == "On" || c == "On") {     

                   this.getField("WellCall").display= display.visible;
                   }

               

                   //othewise make field hidden

               

                   else {
                   this.getField("WellCall").display= display.hidden;
                   }

              • 4. Re: Check boxes / display
                AndyHopkins1965 Level 1

                Thanks again MichaelN,

                 

                It still not working.  I really appreciate your help though.

                 

                Andy

                • 5. Re: Check boxes / display
                  MichaelN Level 3

                  Open the JavaScript console in Acrobat and see exactly what the error message is when you test the form.

                   

                  That will help in identifying the problem.

                  • 6. Re: Check boxes / display
                    AndyHopkins1965 Level 1

                    Hey Michael

                     

                    Here's all that comes up in the JS Console - Debugger

                     

                    Acrobat EScript Built-in Functions Version 10.0

                    Acrobat SOAP 10.0

                     

                    ReferenceError: getfield is not defined

                    3:Field:Calculate

                    ReferenceError: getfield is not defined

                    3:Field:Calculate

                    TypeError: getField("subtotal") is null

                    4:Field:Calculate

                    TypeError: getField("subtotal") is null

                    4:Field:Calculate

                    TypeError: getField("subtotal") is null

                    4:Field:Calculate

                     

                    I don't see anything about the script in question in there.   Thanks again.  Here's my email address if that makes it easier.  andy at andrewhopkins dot net

                    • 7. Re: Check boxes / display
                      MichaelN Level 3

                      I think these errors mean that the names of the fields on your form do not match the names in the script.

                       

                      Make sure you:

                       

                      • Replace "myCheckBox" with whatever the checkbox name is in your form.
                      • Replace "myTextField" with whatever the hidden text field name is in your form.

                       

                      Javascript is case sensitive, so the names in the script must match exactly with whatever the field names are on the form.

                      • 8. Re: Check boxes / display
                        George_Johnson MVP & Adobe Community Professional

                        The correct name of the method is "getField", not "getfield".

                        • 9. Re: Check boxes / display
                          AndyHopkins1965 Level 1

                          Yep, they all match the names of the CheckBox and TextField.  I'm stumped.  Thanks again for the help.

                          • 10. Re: Check boxes / display
                            Test Screen Name Most Valuable Participant

                            Perhaps you can copy/paste back your script as it currently stands. After making sure it doesn't use "getfield" anywhere.

                            • 11. Re: Check boxes / display
                              George_Johnson MVP & Adobe Community Professional

                              Note that the "getfield" error may be in a different script than the one you're working with. It's being reported as an error in a calculation script of one of the fields.

                              • 12. Re: Check boxes / display
                                AndyHopkins1965 Level 1

                                Will do George.  I'll go through and locate those typos.

                                 

                                thanks

                                A

                                • 13. Re: Check boxes / display
                                  AndyHopkins1965 Level 1

                                  How do I find these errors to fix them?  I think I've looked at all the fields that have a script and i can't seem to find them. 

                                   

                                  Acrobat EScript Built-in Functions Version 10.0

                                  Acrobat SOAP 10.0

                                   

                                  ReferenceError: getfield is not defined

                                  3:Field:Calculate

                                  ReferenceError: getfield is not defined

                                  3:Field:Calculate

                                  TypeError: getField("subtotal") is null

                                  4:Field:Calculate

                                  TypeError: getField("subtotal") is null

                                  4:Field:Calculate

                                  TypeError: getField("subtotal") is null

                                  4:Field:Calculate

                                  • 14. Re: Check boxes / display
                                    George_Johnson MVP & Adobe Community Professional

                                    Acrobat lets you edit all JavaScripts at once (look under the JavaScript panel), so you can activate that and search for occurrences of "getfield" and "subtotal" and you will see which fields are affected.

                                    • 15. Re: Check boxes / display
                                      MichaelN Level 3

                                      Also the number 3 or 4 in the error message tells you the line number of the error, which sometimes helps find it.

                                      • 16. Re: Check boxes / display
                                        AndyHopkins1965 Level 1

                                        Thanks so much Michael and George.  I have gone through every field, (I think) and can't find the errors.  I'm stumped.  Somehow I managed to add more?!  Here's the current list on debugger. 

                                         

                                        Acrobat EScript Built-in Functions Version 10.0

                                        Acrobat SOAP 10.0

                                         

                                        ReferenceError: getfield is not defined

                                        3:Field:Calculate

                                        ReferenceError: getfield is not defined

                                        3:Field:Calculate

                                        TypeError: getField("subtotal") is null

                                        4:Field:Calculate

                                        TypeError: getField("subtotal") is null

                                        4:Field:Calculate

                                        TypeError: getField("subtotal") is null

                                        4:Field:Calculate

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        TypeError: f is null

                                        • 17. Re: Check boxes / display
                                          George_Johnson MVP & Adobe Community Professional

                                          Did you use the "Edit All JavaScripts" feature as suggested earlier?

                                          • 18. Re: Check boxes / display
                                            George_Johnson MVP & Adobe Community Professional

                                            Also the "f is null" error is often the result of using one of the built-in calculation methods and one or more of the fields that you specified when setting it up have been renamed or deleted, so it's attempting to use a field that no longer exists.

                                            • 19. Re: Check boxes / display
                                              AndyHopkins1965 Level 1

                                              I tried, but it would let me change anything.  (wasn't sure what I was looking for though)  Here's an example of what I see.

                                               

                                              /*********** belongs to: AcroForm:Tot8:Validate ***********/

                                              if (event.value==0) event.value="";

                                              //</ACRO_script>

                                              //</AcroForm>

                                               

                                              //<AcroForm>

                                              //<ACRO_source>Tot9:Validate</ACRO_source>

                                              //<ACRO_script>

                                               

                                              I tried to Tot9 to Tot8 so they would agree, but it won't change.

                                              • 20. Re: Check boxes / display
                                                AndyHopkins1965 Level 1

                                                I went through and redid each of the calculations.  I might just start over with the fields in question.

                                                • 21. Re: Check boxes / display
                                                  George_Johnson MVP & Adobe Community Professional

                                                  I actually don't like to change anything when lookiing at all of the scripts that way, but you should be able to do a seach and identify which fields are causing the error, by looking for "getfield" and "subtotal". Once you've identified the fields, you can edit the calculation scripts as you normally would.