Auto select multiple items


I have a picklist that is being dynamically populated with values based
on user selections in the form. What I am wanting is to have it
automatically select each item as it is added so that in the end all
items are selected when the form is submitted. I can make the form
select the first item or the most recently added item but I am unable to
get all items selected. I have tried looping through the values but it
seems to be a value behind. I set value 1 and then fire a field event
that gets the values of the target field but it shows no values. Then I
set value 2 and the fire event kicks off again but this time only value
1 is detected. I have tried storing the values in a hidden field so
that I could take a variable that is set to the hidden field value and
pass all the values in the field.select() method that it treats all my
DNs as a single DN value, ex:
"field.select([cn=user1,ou=users,o=data,cn=user2,ou=users,o=data])"


--
gdrtx
------------------------------------------------------------------------
gdrtx's Profile: https://forums.netiq.com/member.php?userid=1660
View this thread: https://forums.netiq.com/showthread.php?t=53059

  • To add and select a new value I'd proceed like this:

    * get all values in the list
    var arAllValues = field.getAllValues()[0]
    * get all selected values in the list
    var arValues = field.getValues()
    * add logic to verify that the new value isn't in the list yet
    loop ..
    * add the new value to the list with
    field.setValues( [ newValue ], [ newValue ], true )
    * add and select the new value
    arValues.push( newValue );
    field.select( arValues );

    Make sure the form field allows for multiple selection

    Good luck

    Wolfgang

    On 09.03.2015 22:20, gdrtx wrote:
    >
    > I have a picklist that is being dynamically populated with values based
    > on user selections in the form. What I am wanting is to have it
    > automatically select each item as it is added so that in the end all
    > items are selected when the form is submitted. I can make the form
    > select the first item or the most recently added item but I am unable to
    > get all items selected. I have tried looping through the values but it
    > seems to be a value behind. I set value 1 and then fire a field event
    > that gets the values of the target field but it shows no values. Then I
    > set value 2 and the fire event kicks off again but this time only value
    > 1 is detected. I have tried storing the values in a hidden field so
    > that I could take a variable that is set to the hidden field value and
    > pass all the values in the field.select() method that it treats all my
    > DNs as a single DN value, ex:
    > "field.select([cn=user1,ou=users,o=data,cn=user2,ou=users,o=data])"
    >
    >