2 Replies Latest reply on Jun 18, 2014 1:18 AM by Americo Pinto

    How to refresh a dropdownlist

    Americo Pinto

      Hi everyone,

       

      I script a dialog box (palette) to import XML files into InDesign Documents. I retrieve xml files shared on a network folder on a dropdownlist. At any moment I need to refresh that list. There, I don't progress anymore.

       

      First I called my dropdownlist items with this function :

      function updateXML ()

      {

           for (var i = 0; i < XMLfromMethode.length; i ++ )

           {

                g.p11.add('item',  XMLfromMethode[i].name);

                }

           }

       

      later I want to renew this list with onClick event :

      g.p12.icoRefresh.onClick = function ()

      {

           g.p11.removeAll();

           updateXML ();

           }

       

       

      Thanks for help.

       

      Best regards

        • 1. Re: How to refresh a dropdownlist
          Trevorׅ Adobe Community Professional
          #targetengine test
          var w = new Window ('palette'),
              d1 = w.add('dropdownlist', undefined, [1,2,3,4,5]),
              b1 = w.add('button', undefined, "Slow Refresh"),
              b2 = w.add('button', undefined, "Fast Refresh"),
              myNewItems = [6,7,8,9,10];
          
          
          b2.onClick = function () {refreshList (myNewItems)};
          b2.onClick = function () {refreshList2 (myNewItems)};
          d1.onChange = function () {alert(d1.selection)};
          function refreshList (newItems) {
              var l = d1.items.length,
                  c;
              while (l--) d1.remove(d1.children[l]);
              l = newItems.length, c;
              for (c = 0; c < l; c++) d1.add('item', newItems[c]);
          }
          
          function refreshList2 (newItems) {
              tempDropdownlist = w.add('dropdownlist', d1.bounds, newItems);
              tempDropdownlist.onChange = d1.onChange; // etc.
              w.remove (d1);
              d1 = tempDropdownlist;
          }
          w.show();
          

           

           

          Trevor

          • 2. Re: How to refresh a dropdownlist
            Americo Pinto Level 1

            Thanks for help. Finally I find out a solution. I define two variables for the same shared folder.

             

            Best regards.

             

            Américo