3 Replies Latest reply on Oct 31, 2011 8:01 AM by BJD79

    Combo Box Manipulation from outside file

    BJD79

      I've looked and looked and looked can't find much info on this. And I'm getting no where. My ultimate goal was to load values from a text file called "data.txt" which would be stored with the pdf form. But I can't even even figure out how to populate the combo box via code. Can anyone help me or tell me if it's even possible to load values from a text file?

       

       

       

      I have a combo box named "ItemCode" but yet I can't figure out how to add items to the box via code only.

      Combo1.gifCombo2.gif

       

      I was doing it on Page 1 Open but it never works for me for no reasons I can not figure out.

       

       

      //-------------------------------------------------------------

      //-----------------Do not edit the XML tags--------------------

      //-------------------------------------------------------------

       

      //<Page-Actions>

      //<ACRO_source>Page1:Page Open:Action1</ACRO_source>

      //<ACRO_script>

      /*********** belongs to: Page-Actions:Page1:Page Open:Action1 ***********/

      var ItemCode = this.getField("ItemCode");

      ItemCode.clearItems();

      ItemCode.setItems("Test");

      //</ACRO_script>

      //</Page-Actions>

       

      //<AcroForm>

      //<ACRO_source>CopyBillAddy:Annot1:MouseUp:Action1</ACRO_source>

      //<ACRO_script>

      /*********** belongs to: AcroForm:CopyBillAddy:Annot1:MouseUp:Action1 ***********/

      var CBA = this.getField("CopyBillAddy");

      var ST = this.getField("Ship_To");

      var BT = this.getField("Bill_To");

      if (CBA.value == 'Yes') {

          ST.value=three.value

      } else if (CBA.value == 'Off') {

          ST.value=ST.value

      }

      //</ACRO_script>

      //</AcroForm>

       

      //<AcroForm>

      //<ACRO_source>Invoice_Number2:Calculate</ACRO_source>

      //<ACRO_script>

      /*********** belongs to: AcroForm:Invoice_Number2:Calculate ***********/

      /** BVCALC Invoice_Number1 EVCALC **/event.value=AFMakeNumber(getField("Invoice_Number1").value)

      //</ACRO_script>

      //</AcroForm>

        • 1. Re: Combo Box Manipulation from outside file
          try67 MVP & Adobe Community Professional

          I have created a script that runs inside of Acrobat and allows you to do

          just that:

          http://try67.blogspot.com/2009/11/acrobat-import-text-file-to-drop-down.html

          • 2. Re: Combo Box Manipulation from outside file
            George_Johnson MVP & Adobe Community Professional

            The argument for the setItems method should be an array, not a string:

             

            ItemCode.setItems(["Test1", "Test2"]);

             

            For more information, see: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.752.html

             

            And also this tutorial: http://acrobatusers.com/tutorials/2007/js_list_combo_livecycle/

            • 3. Re: Combo Box Manipulation from outside file
              BJD79 Level 1

              Thanks finally got it working sort of how I wanted... Learning that there was a debugger console was a real help in figuring out where I was being stupid at. lol

               

              This is the code I ended up using, I know there is very likely about a million ways better to code this but I was never very good with java script. Decided that since this has to be editable by people who have no idea how to use computers very much let alone edit a PDF's javascript or form controls that it would be easier to just load data from 60 text boxes. Sadly the text import/export features seem to be limited by security and don't seem to be functional at all on reader

               

              //-------------------------------------------------------------

              //-----------------Do not edit the XML tags--------------------

              //-------------------------------------------------------------

               

              //<Page-Actions>

              //<ACRO_source>Page1:Page Open:Action1</ACRO_source>

              //<ACRO_script>

              /*********** belongs to: Page-Actions:Page1:Page Open:Action1 ***********/

              var ListData= new Array();

              var ItemCode1 = this.getField("ItemCode.0");

              var ItemCode2 = this.getField("ItemCode.1");

              var ItemCode3 = this.getField("ItemCode.2");

              var ItemCode4 = this.getField("ItemCode.3");

              var ItemCode5 = this.getField("ItemCode.4");

              var ItemCode6 = this.getField("ItemCode.5");

              var ItemCode7 = this.getField("ItemCode.6");

              var ItemCode8 = this.getField("ItemCode.7");

              var ItemCode9 = this.getField("ItemCode.8");

              var ItemCode10 = this.getField("ItemCode.9");

              var ItemCode11 = this.getField("ItemCode.10");

              var ItemCode12 = this.getField("ItemCode.11");

              var ItemCode13 = this.getField("ItemCode.12");

              var ItemCode14 = this.getField("ItemCode.13");

              var ItemCode15 = this.getField("ItemCode.14");

              // var ItemCode16 = this.getField("ItemCode.15");

               

              // Sets the list data pulled from the single line text boxes on Page 2

              for(var i=0; i < 60; i++){

                  ListData[i] = this.getField("DropDownData" + i).value;

               

                      //Exits the loop early if no more data found in the text boxes

                      if (ListData[i] == "") {

                  i = 60

                  }       

              }

               

              // Clears all old items from the combo box lists

              ItemCode1.clearItems();

              ItemCode2.clearItems();

              ItemCode3.clearItems();

              ItemCode4.clearItems();

              ItemCode5.clearItems();

              ItemCode6.clearItems();

              ItemCode7.clearItems();

              ItemCode8.clearItems();

              ItemCode9.clearItems();

              ItemCode10.clearItems();

              ItemCode11.clearItems();

              ItemCode12.clearItems();

              ItemCode13.clearItems();

              ItemCode14.clearItems();

              ItemCode15.clearItems();

              // ItemCode16.clearItems();

               

              // Sets the data into the combo boxes so the accounting users can easily change the data.

              ItemCode1.setItems(ListData);

              ItemCode2.setItems(ListData);

              ItemCode3.setItems(ListData);

              ItemCode4.setItems(ListData);

              ItemCode5.setItems(ListData);

              ItemCode6.setItems(ListData);

              ItemCode7.setItems(ListData);

              ItemCode8.setItems(ListData);

              ItemCode9.setItems(ListData);

              ItemCode10.setItems(ListData);

              ItemCode11.setItems(ListData);

              ItemCode12.setItems(ListData);

              ItemCode13.setItems(ListData);

              ItemCode14.setItems(ListData);

              ItemCode15.setItems(ListData);

              // ItemCode16.setItems(ListData);

               

              // Blanks out all the fields reading it for the user to select the proper data.

              ItemCode1.value = "";

              ItemCode2.value = "";

              ItemCode3.value = "";

              ItemCode4.value = "";

              ItemCode5.value = "";

              ItemCode6.value = "";

              ItemCode7.value = "";

              ItemCode8.value = "";

              ItemCode9.value = "";

              ItemCode10.value = "";

              ItemCode11.value = "";

              ItemCode12.value = "";

              ItemCode13.value = "";

              ItemCode14.value = "";

              ItemCode15.value = "";

              // ItemCode16.value = "";

              //</ACRO_script>

              //</Page-Actions>

               

              //<AcroForm>

              //<ACRO_source>ClearForm:Annot1:MouseUp:Action2</ACRO_source>

              //<ACRO_script>

              /*********** belongs to: AcroForm:ClearForm:Annot1:MouseUp:Action2 ***********/

              var ItemCode1 = this.getField("ItemCode.0");

              var ItemCode2 = this.getField("ItemCode.1");

              var ItemCode3 = this.getField("ItemCode.2");

              var ItemCode4 = this.getField("ItemCode.3");

              var ItemCode5 = this.getField("ItemCode.4");

              var ItemCode6 = this.getField("ItemCode.5");

              var ItemCode7 = this.getField("ItemCode.6");

              var ItemCode8 = this.getField("ItemCode.7");

              var ItemCode9 = this.getField("ItemCode.8");

              var ItemCode10 = this.getField("ItemCode.9");

              var ItemCode11 = this.getField("ItemCode.10");

              var ItemCode12 = this.getField("ItemCode.11");

              var ItemCode13 = this.getField("ItemCode.12");

              var ItemCode14 = this.getField("ItemCode.13");

              var ItemCode15 = this.getField("ItemCode.14");

               

              // Blanks out all the fields reading it for the user to select the proper data.

              ItemCode1.value = "";

              ItemCode2.value = "";

              ItemCode3.value = "";

              ItemCode4.value = "";

              ItemCode5.value = "";

              ItemCode6.value = "";

              ItemCode7.value = "";

              ItemCode8.value = "";

              ItemCode9.value = "";

              ItemCode10.value = "";

              ItemCode11.value = "";

              ItemCode12.value = "";

              ItemCode13.value = "";

              ItemCode14.value = "";

              ItemCode15.value = "";

              //</ACRO_script>

              //</AcroForm>

               

              //<AcroForm>

              //<ACRO_source>CopyBillAddy:Annot1:MouseUp:Action1</ACRO_source>

              //<ACRO_script>

              /*********** belongs to: AcroForm:CopyBillAddy:Annot1:MouseUp:Action1 ***********/

              this.getField("Ship_To").value = this.getField("Bill_To").value;

              //</ACRO_script>

              //</AcroForm>

               

              //<AcroForm>

              //<ACRO_source>DataImport:Annot1:MouseUp:Action1</ACRO_source>

              //<ACRO_script>

              /*********** belongs to: AcroForm:DataImport:Annot1:MouseUp:Action1 ***********/

              this.importTextData("Invoice_data.txt", 0);

               

              //</ACRO_script>

              //</AcroForm>

               

              //<AcroForm>

              //<ACRO_source>DebugClear Items:Annot1:MouseUp:Action1</ACRO_source>

              //<ACRO_script>

              /*********** belongs to: AcroForm:DebugClear Items:Annot1:MouseUp:Action1 ***********/

              var ItemCode1 = this.getField("ItemCode.0");

              var ItemCode2 = this.getField("ItemCode.1");

              var ItemCode3 = this.getField("ItemCode.2");

              var ItemCode4 = this.getField("ItemCode.3");

              var ItemCode5 = this.getField("ItemCode.4");

              var ItemCode6 = this.getField("ItemCode.5");

              var ItemCode7 = this.getField("ItemCode.6");

              var ItemCode8 = this.getField("ItemCode.7");

              var ItemCode9 = this.getField("ItemCode.8");

              var ItemCode10 = this.getField("ItemCode.9");

              var ItemCode11 = this.getField("ItemCode.10");

              var ItemCode12 = this.getField("ItemCode.11");

              var ItemCode13 = this.getField("ItemCode.12");

              var ItemCode14 = this.getField("ItemCode.13");

              var ItemCode15 = this.getField("ItemCode.14");

              var ItemCode16 = this.getField("ItemCode.15");

               

              // Clears all old items from the combo box lists

              ItemCode1.clearItems();

              ItemCode2.clearItems();

              ItemCode3.clearItems();

              ItemCode4.clearItems();

              ItemCode5.clearItems();

              ItemCode6.clearItems();

              ItemCode7.clearItems();

              ItemCode8.clearItems();

              ItemCode9.clearItems();

              ItemCode10.clearItems();

              ItemCode11.clearItems();

              ItemCode12.clearItems();

              ItemCode13.clearItems();

              ItemCode14.clearItems();

              ItemCode15.clearItems();

              ItemCode16.clearItems();

               

              //</ACRO_script>

              //</AcroForm>

               

              //<AcroForm>

              //<ACRO_source>ExportData:Annot1:MouseUp:Action1</ACRO_source>

              //<ACRO_script>

              /*********** belongs to: AcroForm:ExportData:Annot1:MouseUp:Action1 ***********/

              this.exportAsText();

              //</ACRO_script>

              //</AcroForm>

               

              //<AcroForm>

              //<ACRO_source>Invoice_Number1:Annot1:OnBlur:Action1</ACRO_source>

              //<ACRO_script>

              /*********** belongs to: AcroForm:Invoice_Number1:Annot1:OnBlur:Action1 ***********/

              this.getField("Invoice_Number2").value = this.getField("Invoice_Number1").value;

              //</ACRO_script>

              //</AcroForm>

               

              //<AcroForm>

              //<ACRO_source>Print:Annot1:MouseUp:Action1</ACRO_source>

              //<ACRO_script>

              /*********** belongs to: AcroForm:Print:Annot1:MouseUp:Action1 ***********/

              this.print({

                  bUI: true,

                  bSilent: false,

                  bShrinkToFit: true,

                  nStart: 0,

                  nEnd: 0

              });

              //</ACRO_script>

              //</AcroForm>