2 Replies Latest reply on Jul 27, 2015 7:14 AM by MADink_Designs27

    InDesign Buttons and Checkboxes Return Null in JavaScript

    MADink_Designs27 Level 1

      I’m having issues with primarily checkboxes but some buttons as well that were created in InDesign. JavaScript doesn’t seem to like my buttons and checkboxes. I export the pdf from InDesign and define a

       

      JavaScript action on mouse-up and get a JavaScript error such as:

       

      (this is from an event.target script)

      TypeError: this.getField(…) is null
      4:Field:Mouse Up

       

      I get the actual field name if I base the script on the export value. I can fix this by moving the button to a new document, naming it the field to the one with the issue, exporting to pdf, renaming the field in the form so they won't conflict, inserting the pdf as a new page into the form, cutting the field, pasting it into the form, aligning it to the old field, deleting the old field, and adding script. Whew! That's a lot of work. There are hundreds of buttons/checkboxes. It seems random which one will get a null error. To do that with hundreds of fields doesn't seem practical. It's also exported on Acrobat layers to make editing the form easier. Doing this makes the form more difficult to edit because the new buttons don't appear on the layers.

       

      The checkboxes have a custom graphic instead of a checkbox. It seems that this error typically (not always!) removes the graphic and replaces it with a check.

       

      I have plenty of experience in making forms in Acrobat, but this is my first big form using InDesign to create all the fields.

       

      The document was previously created by a co-worker, and I made edits to it including going into each button/checkbox and replacing the image, alt-dragging to create new fields, and renaming buttons.

      The primary actions of the form are to show/hide fields. I prefer JavaScript, so I created code to make it happen. It’s a relatively simple code when it comes to JavaScript.

       

      The actions I have trouble with that absolutely need JavaScript are checkboxes that show/hide fields based on value. I’ve also went the “event.target.isBoxChecked(1)?display.visible:display.hidden” route…but there are typically two checkboxes with the same field name and if you click on one, it makes a button appear for various reasons.

       

      I’m at a loss as to what the issue is. I tried just making most of the actions in InDesign using show/hide a field, converting the buttons back to an object and turning it back into a button, remaking the document from idml, but nothing seems to work.

       

      A lot of the button names are something like “one-10a-check1″. Is it possible acrobat doesn’t like the dashes?

       

      I've been at this over a week and have triple checked the code for error, triple checked the button/checkbox names for errors or spaces, inconsistencies, etc. I haven't found one. I created my code strings in Excel using the Concatenate formula and have copied and pasted the text to minimize any human errors.

       

      Any Other suggestions?

       

      George_Johnson

        • 1. Re: InDesign Buttons and Checkboxes Return Null in JavaScript
          try67 MVP & Adobe Community Professional

          Yes, I've noticed this weird behaivour as well with forms that were created in InDesign. It's seems to be a bug, most likely of ID rather than of Acrobat.

          I would suggest reporting it, and then avoid creating fields in ID. Do it only in Acrobat: Feature Request/Bug Report Form

          • 2. Re: InDesign Buttons and Checkboxes Return Null in JavaScript
            MADink_Designs27 Level 1

            Thanks. I was thinking that it's an InDesign issue as well. I'm on a PC, but the document was created my a co-worker on a Mac. He used PNG's and I went into each button and replaced the graphics with a vector version. I don't know if that was what caused it, but his original file seemed to work and the JavaScript seemed to work...it just wasn't vector and new form fields needed to be added.

             

            The issue with doing it in Acrobat is the need for custom checkbox graphics. It's less of a form and more of a diagram with six vertical slots where different circuit boards fit in. The first have ten options and the last has two (which are options in the first five as well). The checkboxes were used to show solder points.

             

            I guess I could do it sans JavaScript by duplicating buttons on top of each other in InDesign and setting them to show/hide when checked. Each circuit board is a "card" so when each card is opened, it displays a graphic (button) and clickable checkboxes, a close, and reset button. With JavaScript, however, I could set the button to keep the visibility of checkboxes that show a note or another field based on value. That's the only thing I can't replicate...