7 Replies Latest reply on May 16, 2011 6:53 PM by virtual alicia

    Help needed: triggering a combo box selection

    docSquale

      I'm new to creating forms in Acrobat (Acrobat 9 on Mac). I'm trying to create a form for my department where a student selects a faculty name from a combo box, and once the value is selected, another field is filled with an int value (course section number).

       

      Question: what is the correct trigger for executing the javascript for this? Mouse up seems to trigger too early and the others don't seem appropriate.

       

      I think my rudimentary JavaScript knowledge can get me far enough to check the value and the use a switch/if to prefill the int value in the other field, so the correct trigger is my current issue.

       

      Thanks in advance.

        • 1. Re: Help needed: triggering a combo box selection
          MarkWalsh Level 4

          All you need to do is set the 'Export Value' in the combo box for each name to the course number, then set the calculate event of the text field to

           

          event.value = this.getField("Combo Box1").value

           

          Make sure you change 'Combo Box1' to the name of your combobox (spell it exactly as it is named, including case)

          • 2. Re: Help needed: triggering a combo box selection
            virtual_alicia

            Is this the same code for Acrobat X on Windows Vista?

             

            Also, where do I store the master list, or as it's called by thomp in "Programming List and Combo Fields...-Part 1,"an object literal[ly] stored in the document?"

            • 3. Re: Help needed: triggering a combo box selection
              gkaiseril MVP & Adobe Community Professional

              The object is stored as a document level script.

               

              Have you downloaded the sample and looked at all of the coding, including the document level items.

              • 4. Re: Help needed: triggering a combo box selection
                virtual_alicia Level 1

                I found where it's supposed to be stored, but I'm having some issues with missing ().  I'm using Acrobat X Pro for Windows Vista.  There was a post that I've spent the last 2 hours looking for that had a modified code that added in missing (), and now I can't find it   Any help would be greatly appreciated. Anyway, here's my code:

                 

                function mater list for Alpha1()

                var oAlpha1 = {

                ACC: [

                ["-","None"], ["201",Intro to Financial Accounting], ["202",Intro to Managerial Accounting], ["-96",Selected Topics], ["-99",Directed Reading and Research]

                ],

                ANTH: [

                ["-","None"], ["151",Emerging Humanity], ["152",Culture and Humanity], ["210",Archaeology], ["215",Physical Anthropology], ["215L",Physical Anthropology Lab], ["310",Human Origins], ["313",Culture Through Film], ["321",World Archeology], ["342",Indigenous Peoples & Modernity], ["350",Pacific Islands Cultures], ["351",Culture Thought and Behavior], ["358",Myth, Symbol, and Ritual], ["362",Gender, Culture, and Society], "380",Field Archaeology], ["383",Museum Studies], ["384",Human Skeletal Biology], ["415",Human Ecological Adaptation], ["420",Culture & Communication], ["422",Magic Witchcraft & Supernatl], ["423",Social and Cultural Change], ["437",Pacific Archaeology], ["447",Polynesian Cultures], ["448",Micronesian Cultures], ["457",Okinawans Locally & Globally], ["458",Forensic Investigations], ["460",Adv Tech in Forensic Anth], ["474",Culture and Mental Illness], ["483",Archaeology of Hawaii], ["487",Philippine Culture], ["490",History & Theory Anthropology], ["495",Research Seminar], ["496",Selctd Tpcs:], ["499",Directed Reading & Research], ["296F",Intro to Field Archaeology], ["496A",Culture Through Film], ["496B",Phillipines Studies], ["496C",Museum Studies], ["496D",Okinawans Locally & Globally], ["496E",Pacific Island Cultures]

                ],

                APSC: [

                ["-","None"], ["486",Senior Project-Applied Sci], ["490",Senior Practicum], ["486C",Senior Project-CENT], ["486I",Senior Project-IT], ["486M",Senior Project-CULM], ["486R",Senior Project-RESP], ["490C",Admin Practicum-CENT], ["490I",Admin Practicum-IT], ["490M",Admin Practicum-CULM], ["490R",Admin Practicum-RESP]

                ],

                ASTR: [

                ["-","None"], ["110",Survey of Astronomy]

                ],

                 

                It goes on like this through all our subjects.  I then modified the next bits of code in thomp's doc to reflect what I need to be pulled and populated:

                var nACCItems=oAlpha1["ACC"];

                    var n201Title=ACCItems[1]; var n202Title=ACCItems[1]; var n-96Title=ACCItems[1]; var n-99Title=ACCItems[1];

                var nANTHItems=oAlpha1["ANTH"];

                    var n151Title=ANTHItems[1]; var n152Title=ANTHItems[1]; var n210Title=ANTHItems[1]; var n215Title=ANTHItems[1]; var n215LTitle=ANTHItems[1]; var n310Title=ANTHItems[1]; var n313Title=ANTHItems[1]; var n321Title=ANTHItems[1]; var n342Title=ANTHItems[1]; var n350Title=ANTHItems[1]; var     n351Title=ANTHItems[1]; var n358Title=ANTHItems[1]; var n362Title=ANTHItems[1]; var n380Title=ANTHItems[1]; var n383Title=ANTHItems[1]; var n384Title=ANTHItems[1]; var n415Title=ANTHItems[1]; var n420Title=ANTHItems[1]; var n422Title=ANTHItems[1]; var n423Title=ANTHItems[1]; var n437Title=ANTHItems[1]; var n447Title=ANTHItems[1]; var n448Title=ANTHItems[1]; var n457Title=ANTHItems[1]; var n458Title=ANTHItems[1]; var n460Title=ANTHItems[1]; var n474Title=ANTHItems[1]; var n483Title=ANTHItems[1]; var n487Title=ANTHItems[1]; var n490Title=ANTHItems[1]; var n495Title=ANTHItems[1]; var n496Title=ANTHItems[1]; var n499Title=ANTHItems[1]; var n296FTitle=ANTHItems[1]; var n496ATitle=ANTHItems[1]; varn496BTitle=ANTHItems[1]; var n496CTitle=ANTHItems[1]; var n496DTitle=ANTHItems[1]; var n496ETitle=ANTHItems[1];

                var nAPSCItems=oAlpha1["APSC"];

                 

                through all our subjects.  Do I need to leave the lists of var nSUBJItems and var nNUMTitle separate, or is the way I have them (subject followed by titles in each subject) okay?

                 

                Then, I made the keystroke codes.  Do they go in the Document level as well, or do they go in the keystroke event or both?  Right now, I just have them as a doc level code because I can't save the document level code without fixing the () error.  I'd just like to know ahead of time.

                 

                Number Keystroke Event

                 

                function SetNumberEntries()

                {

                if(event.willCommit)

                {

                // Get the numbers list from the Master List

                // Since the selection is being committed,

                // event.value contains the Alpha1 name

                var lst = oAlpha1[event.value];

                // Clear the Number list if there are no numbers for the selected alpha

                if( (lst != null) && (lst.length > 0) )

                this.getField("NumberSelect").setItems(lst);

                else

                this.getField("NumberSelect").clearItems();

                // We have a new number list and the first entry is

                // is a non-selection, so clear the title field.

                this.getField("Title").value = 0;

                }

                }

                 

                 

                Uncommitted Keystroke Event

                 

                function SetTitleValue()

                {

                // In order to get easy access to the export value, i.e. Title. This

                // function needs to be run on the un-committed change event.

                // This field is set up for Commit on select so we know the value

                // will be committed anyway.

                if(!event.willCommit)

                {

                // If the export value is Not written then

                // set the title to --.

                var nSelExp = --;

                if(!isNaN(event.changeEx))

                nSelExp = event.changeEx

                this.getField("Title").value = nSelExp;

                }

                }

                • 5. Re: Help needed: triggering a combo box selection
                  gkaiseril MVP & Adobe Community Professional

                  You should not have a blank in a function name and other items in JavaScript. JavaScript uses white space to parse command lines and determine what the names of objects, parameter values, and what the various words within the command line are. It might be possible to use the special JS escape character to allow a space, but it is easier to omit the space or use an underscore in its place.

                  • 7. Re: Help needed: triggering a combo box selection
                    virtual alicia

                    Even when I try removing the whitespace, i get a general syntax error.  I used to get a syntax error for a missing semicolon, but that has been replaced by the general Syntax Error.  If I can figure out what's wrong, I can make the changes to all the subjects, and this code should run.  (Then it's on to fixing the other parts...)

                    Here's the line with the general syntax error:

                    oAlpha1.ACC):[

                     

                    I get the same error meaasge even if I delete the whitespace so it looks like this:

                    oAlpha1.ACC:[["-","None"], ["201",Intro to Financial Accounting], ["202",Intro to Managerial Accounting], ["-96",Selected Topics], ["-99",Directed Reading and Research]],