0 Replies Latest reply on May 3, 2014 6:13 AM by chinaDDD

    how to display the strings in an array with an dialog box?

    chinaDDD

      I have several strings stored in an array(assuming that we don't know what they are).Now i want to display them on the screen with an dialog box.See the following example:

      If we know  what the strings are, we can do 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:

      {
             "lucy":-1,

             "lily":-2,

              "han":-3

       

      }
      })
      },
      // 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);

       

       

      But if we don't know,do like this ,it returns an error.So how to handle with this problem?

       

      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);