Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Saving multiple selections from Listbox to Text Field

Avatar

Former Community Member
I have a listbox with the 'Allow Multiple Selections' option checked. I would like to save the items the user selects to a text field to cut down on volume when the form is printed.



I placed this Javascript on the Change option, but it only records the last item selected. How can I record all of the selections?



var sNewValue = this.boundItem(xfa.event.newText)

TextField1.rawValue = sNewValue



Thanks!



Andi
2 Replies

Avatar

Former Community Member
The selections are only committed on the exit event of the listbox (when it is multiselect). So on the exit event if you query the rawValue property you will get all of the selections the user made.



The code that you are using will only give you the last entry the user made.



So your code should be moved to the Exit event and it should look like this:



TextField1.rawValue = this.rawValue;



Make sure your text field is multi-line because you will get a CR at the end of each selection. You can use Javascript to parse out the CR to get a single line if you wish.