12 Replies Latest reply on Feb 11, 2015 1:56 PM by kmc27

    Getting "TypeError: f is null" error

    kmc27 Level 1

      I have a series of check boxes on a form for users to select from. In some cases, the user may want to select all of the check boxes. For the cases when the user wants to select all of the boxes, I have a separate "master" check box with the script below attached to it as an action. When the user selects the "master" check box, all of the "slave" check boxes are selected. If the user unselects the "master" check box, all of the "slave" check boxes are unselected.

       

      The issue I am seeing is that when a user selects any of the "slave" check boxes individually, the JavaScript Debugger console displays a "TypeError: f is null" message.

       

      I do not know what the error means, or what, if any, action I need to take, since the script works as expected. Any advice on this would be appreciated.

       

      Thanks in advance for your time.

       

       

      // Get the value of this checkbox

      var v1 = event.target.value;

      // Names of subordinate check boxes

      // and their associated export values

       

      var cb_list = {

      "chk_mkt_bos.0.0" : "1",

      "chk_mkt_bos.1.0" : "1",

      "chk_mkt_bos.2.0" : "1",

      "chk_mkt_bos.3.0" : "1",

      "chk_mkt_bos.0.1" : "1",

      "chk_mkt_bos.1.1" : "1",

      "chk_mkt_bos.2.1" : "1",

      "chk_mkt_bos.3.1" : "1",

      };

       

      if (v1 != "Yes") {

      // turn all other check boxes on

      for (var cb_name in cb_list) getField(cb_name).value = cb_list[cb_name];

      } else {

      // turn all other check boxes off

      for (var cb_name in cb_list) getField(cb_name).value = v1;

      }

        • 1. Re: Getting "TypeError: f is null" error
          gkaiseril MVP & Adobe Community Professional

          Did you check to see that you populated the cb_list with the needed data?

           

          Did you check to see if you are getting the cb_name you expect from the cb_list?

           

          Did you check to see if you actually got the field object as shown in the JS reference manual?

           

          var cb_list = {

          "chk_mkt_bos.0.0" : "1",

          "chk_mkt_bos.1.0" : "1",

          "chk_mkt_bos.2.0" : "1",

          "chk_mkt_bos.3.0" : "1",

          "chk_mkt_bos.0.1" : "1",

          "chk_mkt_bos.1.1" : "1",

          "chk_mkt_bos.2.1" : "1",

          "chk_mkt_bos.3.1" : "1",

          };

          if (v1 != "Yes") {

          // turn all other check boxes on

          var oField;

          for (var cb_name in cb_list) {

          console.println(cb_name);

          oField = this.getField(cb_name)

          if(oField == null) "app.alert("Check if field " + cb_name + " exist.", 0,1);

          oField.value = cb_list[cb_name];

          } else {

          // turn all other check boxes off

          for (var cb_name in cb_list) {

          oField = this.getField(cb_name)

          if(oField == null) "app.alert("Check if field " + cb_name + " exist.", 0,1);

          oField.value = v1;

          }

           


          • 2. Re: Getting "TypeError: f is null" error
            Bernd Alheit Adobe Community Professional & MVP

            Where did you use the code?

            • 3. Re: Getting "TypeError: f is null" error
              George_Johnson MVP & Adobe Community Professional

              It doesn't look like that code is the source of the problem. There is no variable f, so you should look for it elsewhere. I suspect the source is a calculated field that includes a nonexistent field in the calculation.

              • 4. Re: Getting "TypeError: f is null" error
                gkaiseril MVP & Adobe Community Professional

                If one uses one of the other methods of creating a calculation, like the field is the ___ of... or simplified field notation, and a field is used in that method is renamed or deleted, one will get this type of error. Those 2 methods are front ends to some JavaScript functions that use the "f" variable as field object.

                • 5. Re: Getting "TypeError: f is null" error
                  kmc27 Level 1

                  Below is how I am using the script. The script is attached to the red checkbox labeled "Group Select". When a user checks the "Group Select" checkbox, the script puts a checkmark in each of the checkboxes in front of each location number. This is just a shortcut for the user, so that they can mass select all of the locations at once, and if needed, unselect the one or two the do not need. In other sections of the form, there are regions that have over 100 locations. For those regions, having a way to select all of the locations at once is very handy.

                   

                  There is no calculation on the checkboxes themselves. They are either on or off. I don't know what data they would need to be populated with in order for the script to work without erroring. And the checkbox field names are correct.

                   

                  As for calculations, the text boxes to the right of each location are used for entering quantities, and those text boxes are totaled up on another text field on the form. But I am not really calculating anything with the checkboxes, unless the act of checking them for a value is considered a calculation.

                   

                  checkbox example.gif

                  • 6. Re: Getting "TypeError: f is null" error
                    gkaiseril MVP & Adobe Community Professional

                    Do you really understand how JavaScript is processed within a form?

                     

                    You are only providing an error text, but the full error description include the field or function, the line number, and the action being performed. All of this additional data will help identify were the error actually is not where you think it is occurring. Please provide a link to a sample from.

                    • 7. Re: Getting "TypeError: f is null" error
                      kmc27 Level 1

                      I must not understand how JavaScript is processed within a form. This is the only information I see in the debugger when I click on one of the location checkboxes. If I click on the "Group Select" button, I get the same message. How do I get it to display more details about the the error? I'll try some of the other region sections of the form  (configured the same way) and see if they produce the same results in the debugger.

                      javascript_debugger.gif

                      • 8. Re: Getting "TypeError: f is null" error
                        kmc27 Level 1

                        I went back into my form and deleted the script on the "Group Select" checkbox. I still get the "TypeError: f is null" message when clicking the location checkboxes.  The checkboxes have an export value of "Yes". They do not have an action attached to them. The forms were created using Acrobat X, Windows. They have also been edited using Acrobat XI on a Macintosh.

                        • 9. Re: Getting "TypeError: f is null" error
                          gkaiseril MVP & Adobe Community Professional

                          Again, it might be best if you can provide a link to your form a sample form with the problem.

                          • 10. Re: Getting "TypeError: f is null" error
                            kmc27 Level 1

                            An example of the form is here

                             

                            The checkbox that gives the error is the "Group Select" checkbox shown below.  They are used on pages 2 and 3 of the form.

                            AcrobatScreenSnapz001.gif

                            For what it is worth, the script does work and all the location boxes are either selected or unselected when the "Group Select" box is checked and unchecked. As you will see the form is kind of big and unwieldy, it has "evolved" from a smaller form to the size it is today. It probably would be more efficient as a web application, but the users who process the forms like the "at-a-glance" view of all the locations and the print-ability of a PDF.

                             

                             

                            Thanks again for any ideas on this.

                            • 11. Re: Getting "TypeError: f is null" error
                              George_Johnson MVP & Adobe Community Professional

                              That link is not valid.

                              • 12. Re: Getting "TypeError: f is null" error
                                kmc27 Level 1

                                Sorry, somehow I truncated the path when I made the link. Here is a working link.