2 Replies Latest reply on Apr 6, 2012 5:10 AM by Selva_TRM

    Can we create Dropdown list as variable?

    Selva_TRM Level 1

      Hi all

       

      Can we create Dropdown list with variable texts. I am trying to do this, but locked. my code is

       

      var myTable = myText.convertToTable();

      var myRowCount = myTable[0].rows.count();

       

      var e = "";

      for (i = 0; i<=myRowCount-1; i++){

          e = "\""+myTable[0].rows[i].contents+"\", "+e;

          }

      var s = "["+e.toString()+"]";

      alert(s);

       

      var myDialog = app.dialogs.add({name: "Choose Printer Preset"});

              with (myDialog.dialogColumns.add()){

                  staticTexts.add({staticLabel:"Presets: "});

              }

              with (myDialog.dialogColumns.add()){

                      var myList = dropdowns.add({stringList: s, selectedIndex:1});

              }

          var result = myDialog.show();

       

       

      So, i have create table with some text, then, give it to the dropdown list parameter, but i got "invalid parameter" error message.

       

      Any suggestion please.

       

      Thanks

      Selva

        • 1. Re: Can we create Dropdown list as variable?
          csm_phil Level 4

          Hi Selva,

           

          I have modified your above JS code, i hope you expected this! Check and revert.

           

           

          var myDoc = app.activeDocument;
          var myText = app.selection[0];
          var myTable = myText.convertToTable();
          var myRowCount = myTable.rows.count();
          
          var Arr = [];
          for (i = 0; i<=myRowCount-1; i++){
              //Arr.push(myTable.rows[i].contents+"\r");
               Arr.push("\""+myTable.rows[i].contents+"\", ");
              }
          //alert(Arr);
          
          var myDialog = app.dialogs.add({name: "Table Text"});
          with (myDialog.dialogColumns.add()){
               staticTexts.add({staticLabel:"Row Texts: "});
               }
          with (myDialog.dialogColumns.add()){
               var myList = dropdowns.add({stringList:Arr, selectedIndex:0});
               }
          var result = myDialog.show();
          

           

           

          thx

          csm_phil

          • 2. Re: Can we create Dropdown list as variable?
            Selva_TRM Level 1

            wow!!!

             

            thanks phill

             

            That is what i want, for this i spent more than four hour in my office time.

             

            I have used another methodology,  i created dummy printer presets using the list text and then call it to dropdown parameter, it also works!

             

            but i know its not proper way.

             

            now you give me the good solution.

             

            Thanks again

            Selva