Populate List Collector From Another List Collector

arobertson
Tera Guru

Hi,

 

I have a form with two list collectors. One is for adding group owners and the second is for adding group members.

 

I would like the group members list collector to populate with what ever is in the group owners list collector. Is this possible?

11 REPLIES 11

harikrish_v
Mega Guru

Thanks.



I think that just lets you copy from left to right on the same list collector.



I need to copy from one list collector to another, most probably onChange.


No its the same one you need. If you read the post, you will see this "Just supply the name of the list collector variable you are working with, and then make sure you provide an array of option IDs to move from one side to another. The option IDs need to be added to the 'selectedIDs' array in the middle chunk of code", this array of options will come from your first list collector


Sorry, got a bit confused.



So far, i have the following: my two lists collectors are called "admin_group_owners" and "groups_members".



I have added "admin_group_owners" to line 7 as this is the list collector i want to copy the values from.



function onChange(control, oldValue, newValue, isLoading) {


      if (isLoading || newValue == '') {


              return;


      }


   


      //Name of variable to move options from


      var varName = 'admin_groups_owners';


      var leftBucket = gel(varName + '_select_0');


      var rightBucket = gel(varName + '_select_1');


      var selectedOptions = rightBucket.options;


   


      //Get an array of all option IDs to move


      var selectedIDs = new Array();


      var index = 0;


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


              selectedIDs[index] = i;


              index++;


      }


   


      //Move all returned options from right to left bucket and sort the results


      //Switch 'rightBucket' and 'leftBucket' to move from left to right


      moveSelectedOptions(selectedIDs, rightBucket, leftBucket, '--None--');


      //Sort the resultant options in the left bucket


      sortSelect(leftBucket);


   


}