Discussion Locked

Using a list Box

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am going nuts.
How do I use dhtml to move items in a listbox control. I am familiar with the options collection but can not see how to move the items around with either vb or java script. If I have a list with the items: mike,joe, carol.
When I select carol and click a button I need for her name to appear second in the list. Basically I want the selected item to move up in the list. Then I have another button to move items down. I want full
control to move items up and down and order the list this way.

6 replies

by donq

I am unable to define exactly what you want from your current wording. It sounds as though you want something to act as a variable "ordinal position" sort for a predefined (and fixed) list of names??? If that is correct set your data source up using a numerical field to sort records just as every ODBC complient database product does. Then you could just "drag and drop" whatever you wanted to change within the list???

by donq

stay away from alphabetical sorts unless a default setting will work for every case!

by parkin_thom

If you place the entire list within a DIV tag, you can use Javascript to rewrite the list.
There are a number of ways to code this (elegant to downright sloppy), so I cannot just do it for you.
But as an example,
listing.innerHTML=listarray[0] + listarray[1] + listarray[3]; //etc.
And the listarray would be where you manipulate the order. It's elements would be such as:

Does this help?
But, I will bet that if you can describe accurately what it is you really need to accomplish, there may be far better ways than this clicking on the list.
How about checkboxes beside each item that indicate its rank? We simply don't understand your ultimate purpose on this project.

THOM
twice21.com

This discussion is closed to new replies.