Anonymous_User Absent Member.
Absent Member.
251 views

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

Labels (1)
0 Likes
1 Reply
Anonymous_User Absent Member.
Absent Member.

Re: Auto select multiple items

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])"
>
>

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.