Go4Expert (http://www.go4expert.com/)
-   JSP (http://www.go4expert.com/forums/jsp/)
-   -   Need Help w/ Drag&Drop in Listbox (http://www.go4expert.com/forums/help-dragdrop-listbox-t20708/)

melvinlui 20Jan2010 13:33

Need Help w/ Drag&Drop in Listbox

I've just created a dynamic listbox in JSP using the <SELECT> tag. However, i need to come up with a code to allow the users to drag and drop the items in the listbox to rearrange them in the order the user prefers.

Is this possible by using JSP? if so, how can it be done? can anyone shed a light or two? :)


venami 20Jan2010 20:27

Re: Need Help w/ Drag&Drop in Listbox
These can be done using JavaScript easily. But can you explain more on your need?

melvinlui 20Jan2010 20:47

Re: Need Help w/ Drag&Drop in Listbox
Hi Venami,

Thank you for your reply.
What i have is a listbox containing column headers that i have extracted from a database, and i need to be able to rearrange them according to the order that i want and save it back into the database. The problem is i do not know how to do a drag and drop for a list box. below will be an example of how i have done it:


<SELECT NAME='userId'>
        String sqlUserIdSelect = "SELECT DISTINCT UserId FROM kplustp..ProfilingGridFieldUser";
        stmt = con.createStatement();
        resultSet = stmt.executeQuery( sqlUserIdSelect );

        int userRowNum = resultSet.getRow();
        int userColNum = resultSet.getMetaData().getColumnCount();
        int a=1;
            while ( resultSet.next() )
              for( int b=1 ; b<=userColNum ; b++ )
                  String userColResult = resultSet.getString( b );

                  out.println( "<OPTION VALUE='" + userColResult + "' ");
                        if (userId!=null && request.getParameter("userId").equals(userColResult))
                  out.println(">" + userColResult + "</OPTION>" );

Basically it is just a <SELECT> listbox, but i need to move the elements within it up and down by drag and drop to rearrange them. if still not clear, maybe i could upload some pictures to show you a clearer example?

All times are GMT +5.5. The time now is 13:32.