3 Replies Latest reply on Sep 10, 2013 8:10 AM by Jia.Yi

    Document-level javascript quandry


      Ok, completely clueless newbie here whose only coding experience is Access VBA…from a few years ago. Need to write up some Javascript to make this work – that was a month’s worth of a migraine.  I ask for your patience, and would like to ask for forgiveness in advance for any headaches I induce while you try to figure out my problem(s).  Also, I’m not sure how to copy paste images or code examples, but I will do my best.



      So, basic premise:  make a drop-down combo box that will populate another combo box based on whatever was selected in the first box – in this case, 31 items in the ‘Inventory Parts Used’ list, and a total of 427 respective sizes in the other list. 



      YES, I’ve already looked at that http://acrobatusers.com/tutorials/js_list_combo_livecycle1 example, and followed it closely.  Took me forever, but I somehow got it to work. Was very happy.  Only thing I couldn’t figure out was the export value b/c mine wasn’t a number.  But I solved that by putting the CodeID and respective PartSize together (ex: 4-inch Fire Hydrant would show up as "FH-01:  4"). Anyways, I selected that working row and choose the “Place Multiple Fields” option times 15 rows.  Still working.  I’m dancing a jig. Then I tried to check on the code: 



      “Text cannot be displayed in full by the Edit Dialog.  Please use an External Editor.” 



      Uh… So I deleted a row at a time until I could see what my limit was.  I had to pare down 15 rows to a measly 3 rows.  Took me a while but I was able to see where the problem was.  Instead of being written into the Document-Level JS, my array was tied to the first combo box’s Keystroke event on the Field Level.  So when I multiplied the rows, that humongous list essentially had diarrhea.


      I’ve tried to delete that header and keep it to Document Level.   It basically ignored me and keep those lines.  When I did manage to make the <Document-Level> on top, it just didn’t work.

      (    //<AcroForm>



      /*********** belongs to: AcroForm:Row0.InvPart:Keystroke ***********/    )


      I’ve searched other forums about the Document-level…. I swear I read a lot of forums that said using Advanced>Document Processing>Set Document Actions>Edit All was ok. Clearly it’s not ok, especially after I found this forum: http://answers.acrobatusers.com/Where-I-enter-document-level-javascript-adding-FormRouter- Calendar-q55527.aspx


      So I guess my question(s) is this:  IS that “Edit Document Javascripts” really necessary?  B/c I’ve looked and I don’t have it. I’m using Adobe Acrobat 9 Standard, ver 9.5.5 (and I’m using Windows XP Pro ver 2002 , if that matters).  Is this JS editor only available to the Pro version?  Would it really be a bad thing to just leave it alone as a keystroke event (aside from the unwieldy large, duplicated codes it vomits as a result)? Or maybe, is there a way to code a new row on instead?  I remember seeing an example where you can add more lines as needed, but I can’t for the life of me find it again.


      Thank you in advance for all your assistance.

        • 1. Re: Document-level javascript quandry
          Jia.Yi Level 1

          * Huh....it just figures... right after I finally give up and post up a question, I would find the answer. =_=;; http://forums.adobe.com/message/4727325#4727325


          So, Standard version apparently doesn't have that exalted “Edit Document Javascripts”.  Apparently a way around it is using the Page Open event.  Well, it works - the massive array only shows up once in the editor, and the multiple rows each call the function instead.  Nice. 


          Well, I will leave this up in case someone else can use the reference.  Thanks to anyone who read this and was going to answer me. =)




          Don't suppose anyone knows how to create a code to add new rows instead of having 15 rows straight off the bat?  Or should I make a new post for that?

          • 2. Re: Document-level javascript quandry
            gkaiseril MVP & Adobe Community Professional

            The "Document JavaScripts" is available only with the Professional version.


            The "Document All JavaScripts" contains special XML tags that must be maintained or your form could become completely unusable. Advance programmers may use this to quickly change a variable name that appears in many different scripts within a PDF but even they will have a problem if they accidentally delete one of the tags.


            For efficiency with large PDF forms and forms with a large number of scripts it makes a difference. First the document level scripts are fully processed only once and not each time the field is used in a calucation.


            One can use the addScript method to add a script as document level script, but users with standard will not be able to see it.


            You could put the script in the Page Open action and for a 1 page form this would be like processed like a document level script.

            • 3. Re: Document-level javascript quandry
              Jia.Yi Level 1

              I think that's the clearest explantion that I've seen yet GKaiseril, thanks.  


              Yeah, I wish all those 'How-To's' and informational articles had mentioned that the Document Javascript editor was something unique to the Pro versions.  Or, as you say, you CAN add to the document-level....you just wouldn't be able to see it... Yeesh... how meeeeaaaan


              Yeah, this is a 1-page form that I was making.... although technically it's the "backside" of the paper form.  We're going to field test it and see how it goes.... Right now, I have no idea how it will tie-in with the "front side" information, if it will even be a PDF, so I may or may not need to figure out that addScript thing that you mentioned.


              Thanks again!