3 Replies Latest reply on Apr 26, 2014 10:15 AM by chinaDDD

    help with dialog list box(acrobat javascript)

    chinaDDD

      The following code is an example in the guide of acrobat. Now i want to list some names store in an array. So i did some changes.But it can't work.ther are errors with subl:{}. hope some help.

       

      var dialog3 = {

       

      name=new Array();

      name[1]=lucy;

      name[2]=lily;

      name[3]=han;

      // This dialog gets called when the dialog is created

      initialize: function(dialog) {

      this.loadDefaults(dialog);

      },

      // This dialog gets called when the OK button is hit.

      commit: function(dialog) {

      // See the Dialog Object for a description of how dialog.load

      // and dialog.store work.

      var elements = dialog.store()["subl"];

      // do something with the data.

      },

      // Callback for when the button "butn" is hit.

      butn: function(dialog) {

      var elements = dialog.store()["subl"]

      for(var i in elements) {

      if ( elements[i] > 0 ) {

      app.alert("You chose \"" + i

      + "\", which has a value of " + elements[i] );

      }

      }

      },

      loadDefaults: function (dialog) {

      dialog.load({

      subl:

      {

           for(i=1;i<4;i++)

           {

                name[i]:+i

           }

      }

      })

      },

      // The Dialog Description

      description:

      {

      name: "Adobe Acrobat Products", // Title of dialog

      elements: // Child Element Array

      [

      {

      type: "view",

      align_children: "align_left",

      elements: // Child Element Array

      [

      {

      type: "cluster",

      name: "Select",

      elements: // Child Element Array

      [

      {

      type: "static_text",

      name: "Select Acrobat you use",

      font: "default"

      },

      {

      type: "list_box",

      item_id: "subl",

      width: 200,

      height: 60

      },

      {

      type: "button",

      item_id: "butn",

      name: "Press Me"

      }

      ]

      },

      {

      type: "ok_cancel"

      }

      ]

      }

      ]

      }

      }

       

      app.execDialog(dialog3);

        • 1. Re: help with dialog list box(acrobat javascript)
          chinaDDD Level 1

          sorry ,the code is like this:

           

          name=new Array();
          name[1]='lucy';
          name[2]='lily';
          name[3]='han';
          var dialog3 = {

          // This dialog gets called when the dialog is created
          initialize: function(dialog) {
          this.loadDefaults(dialog);
          },
          // This dialog gets called when the OK button is hit.
          commit: function(dialog) {
          // See the Dialog Object for a description of how dialog.load
          // and dialog.store work.
          var elements = dialog.store()["subl"];
          // do something with the data.
          },
          // Callback for when the button "butn" is hit.
          butn: function(dialog) {
          var elements = dialog.store()["subl"]
          for(var i in elements) {
          if ( elements[i] > 0 ) {
          app.alert("You chose \"" + i
          + "\", which has a value of " + elements[i] );
          }
          }
          },
          loadDefaults: function (dialog) {
          dialog.load({
          subl:

          {
                for(i=1;i<4;i++)
          {
                  "name[i]":-i
          }
          }
          })
          },
          // The Dialog Description
          description:
          {
          name: "Adobe Acrobat Products", // Title of dialog
          elements: // Child Element Array
          [
          {
          type: "view",
          align_children: "align_left",
          elements: // Child Element Array
          [
          {
          type: "cluster",
          name: "Select",
          elements: // Child Element Array
          [
          {
          type: "static_text",
          name: "Select Acrobat you use",
          font: "default"
          },
          {
          type: "list_box",
          item_id: "subl",
          width: 200,
          height: 60
          },
          {
          type: "button",
          item_id: "butn",
          name: "Press Me"
          }
          ]
          },
          {
          type: "ok_cancel"
          }
          ]
          }
          ]
          }
          }

          app.execDialog(dialog3);

          • 2. Re: help with dialog list box(acrobat javascript)
            try67 MVP & Adobe Community Professional

            This code returns an error. Also, in the load command you can't include an entire for-loop, as far as I know. You need to prepare the object you want to load before-hand and then just apply it in the load command.

            • 3. Re: help with dialog list box(acrobat javascript)
              chinaDDD Level 1

              thanks. I write a code to search the bookmarks that i want  and i need to display the results in a dialog box,so how to realize this function?