Highlighted

Saving multiple selections from Listbox to Text Field

Avatar

Guest

03-09-2008

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

Replies

Highlighted

pguerett

04-09-2008

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.