Drop and down / list box manipulation

679 views
Skip to first unread message

smekerus

unread,
May 19, 2008, 3:49:00 AM5/19/08
to Adobe LiveCycle Developers
Hello!

I need help, if possible, with a problem:

a) I have a drop and down list and a list box which is display the
selections from the drop and down list.

listbox1.addItem(xfa.event.newText);

I need to be able to remove from the drop and down list at the same
time the selections added to listbox1. If I select "item 1" in drop
and down list and it goes to Listbox1 I need to remove it from drop
and down to avoid being selected twice.

Beside that I need to know if there's a method to actually increase
dynamically the size (height) of the listbox1 based on the number of
items added to it. I don't want to use scrollbars because the form
will be printed and all items selected should be visible.

fred.pantalone

unread,
May 20, 2008, 10:25:40 AM5/20/08
to Adobe LiveCycle Developers
Here's an approach:

Use these two JavaScript methods to add and remove items from drop-
down lists and list boxes:

addItem()
deleteItem()

When you create the drop-down list, at form design time, populate the
"value" portion of the drop down item with the index of that item.
E.g. (text/value):

Red/0
Blue/1
Green/2
Black/3

When an item is selected from the drop down list, use the value (i.e.
the index of the selected item) to call deleteItem() on the drop-down.
Then, call addItem() on the list box using the text from the drop down
selection. However, before you do this get the current size of the
list box with this code:

this.items.nodes.length

and use this as the "value" in the call to addItem().

I don't think you can get the list box to grow, you might have to pre-
size it (at design time) to fit all of the items.

I hope this isn't too confusing and gives you a start...

Fred

LiveCycle Lifeline

unread,
May 21, 2008, 10:00:56 AM5/21/08
to Adobe LiveCycle Developers
send me your form will try to work out some sort of solutiion for you
thanks
girish
> > will be printed and all items selected should be visible.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages