Need Help w/ Drag&Drop in Listbox

Discussion in 'JSP' started by melvinlui, Jan 20, 2010.

  1. melvinlui

    melvinlui New Member

    Joined:
    Jan 20, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    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? :)

    Melvin
     
  2. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    http://mvenkatapathy.wordpress.com
    These can be done using JavaScript easily. But can you explain more on your need?
     
  3. melvinlui

    melvinlui New Member

    Joined:
    Jan 20, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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:

    Code:
    <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("SELECTED");}
    		  out.println(">" + userColResult + "</OPTION>" );
    		}
    	}
    %>
    </SELECT>
    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?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice