Page 1 of 1

Valuelist keeps displaying previous choice

PostPosted: Thu Jan 17, 2008 1:34 pm
by Dirc
I've made a valuelist, displaying directories on a FTP server.
I can choose one in a valuelist, click a button and the subdirectory is indexed.

Now the problem is, that when the subdirectorie is indexed, the chosen value (so in this case the name of the subdirectory) is still in the valuelist as selecteditem.

The problem of this is that an user can select the same item again, wheter the item really exists or not.

I want to totally reset my valuelist after making a selection.

Code:
Code: Select all
application.output(globals.selectedMap)
globals.ftp = ""
globals.customdir += "/" + globals.selectedMap
var values = new Array()
application.setValueListItems('maps',[''],[null]);


// Create a client for the JFTP connection
var client = plugins.it2be_ftp.createJFTPclient(xxxx, xxxxx , xxxx);

// 'Build' the connection and when the connection returns true
// start executing the rest of the code
if (client.connect()) {
   globals.ftp = "";
   application.output("working path:" + client.getWorkingPath())
   client.cd(globals.rootdir + globals.customdir)
   // Check the status of the connection
   application.output(client.getStatus());

   // Create a list (array) of JFTPFiles
   var list = client.list();
   if (list != null) {
      // Loop through the JFTPFiles
      for (var i = 0 ; i < list.length ;i++) {
         
         // Output the name, size and timestamp of the JFTPFile
         if(list[i].isDirectory){
            if(list[i].name!="."){
               values.push(list[i].name)
            }
         }
         if(list[i].isFile){
         globals.ftp += list[i].name + "\n";
         }
      }
      application.setValueListItems('maps',values);
   }
   if (globals.ftp == "" || !globals.ftp)
   {
      globals.ftp = "Deze directory bevat geen bestanden."
   }
   // Disconnect the client
   client.disconnect();
}